try_promote_i32_arith

Function try_promote_i32_arith 

Source
fn try_promote_i32_arith(b: &BinaryExpr, ctx: &mut WalkCtx<'_>)
Expand description

Promote an i32 operand of an f32 ⟦arith⟧ i32 binop to f32 by wrapping it in float(…). WGSL refuses mixed f32 * i32 arithmetic; corpus shape (martin - pixies party 2 random mosscity.milk):

for (int n=1; n<=anz; n++) {
    z = 1 - fract(1.0*n/anz - 1.0*fract(-t_rel/anz));
}

After for_init, n: i32. The condition’s n <= anz already gets a f32(n) cast from try_broadcast_scalar_compare; the body’s 1.0*n needs the same treatment.