Skip to content

Commit

Permalink
Naga(msl): Clear named expressions after writing each function (#4594)
Browse files Browse the repository at this point in the history
This appears to match other backends, and fixes
fix the case where expressions which were named in earlier
functions are used in local variable declarations
  • Loading branch information
DJMcNab authored and cwfitzgerald committed Nov 15, 2023
1 parent ca96cb4 commit 9d57a60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3643,10 +3643,10 @@ impl<W: Write> Writer<W> {
writeln!(self.out, ";")?;
}

self.named_expressions.clear();
self.update_expressions_to_bake(fun, fun_info, &context.expression);
self.put_block(back::Level(1), &fun.body, &context)?;
writeln!(self.out, "}}")?;
self.named_expressions.clear();
}

let mut info = TranslationInfo {
Expand Down Expand Up @@ -4313,13 +4313,13 @@ impl<W: Write> Writer<W> {
writeln!(self.out, ";")?;
}

self.named_expressions.clear();
self.update_expressions_to_bake(fun, fun_info, &context.expression);
self.put_block(back::Level(1), &fun.body, &context)?;
writeln!(self.out, "}}")?;
if ep_index + 1 != module.entry_points.len() {
writeln!(self.out)?;
}
self.named_expressions.clear();
}

Ok(info)
Expand Down

0 comments on commit 9d57a60

Please sign in to comment.