laurentlb / shader-minifier

Minify and obfuscate GLSL or HLSL code
https://ctrl-alt-test.fr/minifier/
Apache License 2.0
424 stars 29 forks source link

Shadow variables inside loops and if statements #387

Closed laurentlb closed 1 month ago

laurentlb commented 1 month ago

In the past, we used the shadowing mechanism only when entering functions. Now, we do if in loops and if statements too.

Note that scopes often don't start at the blocks (curly braces). In a function, arguments are part of the function body scope. In a for-loop, the init declaration is part if the for-loop body too, even if there are curly braces. For this reason, we don't apply shadowing at the block level.

Fixes https://github.com/laurentlb/shader-minifier/issues/382