End a for body's hiding at a rewritten return/discard statement too

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
JoansitohandClaude Sonnet 5.5 committed 2026-11-01 20:39:44 +01:00
1 parent 93ce3a81a7
commit 9696cd39ea
2 files changed
+18

No files matched your search

@@ -2317,6 +2317,17 @@ mod tests {
)
.unwrap_or_else(|e| panic!("{e:?}"));
assert!(reads_bool_uniform(&p));
// The body is a `return`, which the translator rewrites on its own.
let fsh = "#version 330\nuniform bool hideGUI;\nout vec4 c;\n\
float f(float t) {\n \
for (bool hideGUI = false; t < 2.0; t += 1.0) return hideGUI ? 1.0 : t;\n \
return hideGUI ? 1.0 : 0.0;\n}\n\
void main() { c = vec4(f(0.0)); }\n";
let p = program(
&[("composite.vsh", VSH_120), ("composite.fsh", fsh)],
Target::Buffers,
);
assert!(p.is_ok(), "{:?}", p.err());
}
/// A sampler parameter's name reused as a local of an inner block, then read again.
@@ -132,6 +132,13 @@ impl Stage<'_> {
{
out.push_str(close);
statement_close = None;
// This `;` may end the single-statement body of a `for`.
if calls.is_empty() && unbraced_for.last() == Some(&depth) {
while unbraced_for.last() == Some(&depth) {
unbraced_for.pop();
}
hidden.retain(|&(_, _, d)| d <= depth);
}
continue;
}
if let Some(text) = self.replaced.get(&i) {