On Thu Jun 29 10:46:21 2023 +0000, Giovanni Mascellani wrote:
There is some problem with how loop scoping is handled here. For example, this is accepted by native and not by us:
float4 main() : sv_target { for (int y = 0; y < 1000; y++); return float4(y, 0.0, 0.0, 0.0); }
However this is broken also before this MR, so I'm not insisting on this, just wanted to mention it. I'm not sure right now on what is the best solution to handle scopes here, and the proposal doesn't look more broken than the current state, so it's ok for me.
Yes, this is something unrelated, and unexpected too. Essentially what it does is replaces any declarations in outer scope, but only one level up. If you had 'int y = 1;' in your example before the loop, compiler produces a warning, but still uses what was declared in the loop. If however you enclose the loop in its own block, it does not do that, and loop will be eliminated.
Definitely something to fix, and trivial to test too.