[glsl-in] lost statement of multi part loop-expression
Description
If the third expression of a for loop (loop-expression according to the spec Chapter 6.3) contains multiple statements... naga just takes the last one and forgets the the first. I haven't looked at more than two statements.
this leads to infinite loops and potential crashes. Likely root cause to finding https://github.com/gfx-rs/wgpu-native/issues/416, maybe related to https://github.com/gfx-rs/wgpu/issues/4558
Repro steps I have two semantically equivalent code snippets in glsl
for (int i = 0; i < 50; i+=1, b+=0.01) {
a -= 0.01;
}
for (int i = 0; i < 50; b+=0.01, i+=1) {
a -= 0.01;
}
the third expression contains the usual incrementor, as well as a completely unrelated statement.
translating them to wgls using naga gives me the following output for this loop
loop {
let _e22 = i;
if !((_e22 < 50i)) {
break;
}
{
let _e29 = a;
a = (_e29 - 0.01f);
}
continuing {
let _e26 = b;
b = (_e26 + 0.01f);
}
}
loop {
let _e22 = i;
if !((_e22 < 50i)) {
break;
}
{
let _e29 = a;
a = (_e29 - 0.01f);
}
continuing {
let _e26 = i;
i = (_e26 + 1i);
}
}
the difference is which statement is part of the continuing block. The other statement is completely lost. It is dependant on the order.
Expected vs observed behavior A reference for this being valid in a shadertoy. Perhaps the continuing block could just include both statements?
Platform naga 22.0.0
I have just encountered issues with multiple statements in init-expression too so perhaps it applies to both parts