Skip to content

fix(wgsl-in): increase brace limit to 127 #7412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions naga/src/front/wgsl/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3120,12 +3120,7 @@ impl Parser {
// > …
// >
// > Maximum nesting depth of brace-enclosed statements in a function[:] 127
//
// _However_, we choose 64 instead because (a) it avoids stack overflows in CI and
// (b) we expect the limit to be decreased to 63 based on this conversation in
// WebGPU CTS upstream:
// <https://github.com/gpuweb/cts/pull/3389#discussion_r1543742701>
const BRACE_NESTING_MAXIMUM: u8 = 64;
const BRACE_NESTING_MAXIMUM: u8 = 127;
if brace_nesting_level + 1 > BRACE_NESTING_MAXIMUM {
return Err(Box::new(Error::ExceededLimitForNestedBraces {
span: brace_span,
Expand Down
71 changes: 62 additions & 9 deletions naga/tests/wgsl_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2699,12 +2699,12 @@ fn limit_braced_statement_nesting() {
let too_many_braces = "fn f() {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{";

let expected_diagnostic = r###"error: brace nesting limit reached
┌─ wgsl:1:72
┌─ wgsl:1:135
1 │ fn f() {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
│ ^ limit reached at this brace
^ limit reached at this brace
= note: nesting limit is currently set to 64
= note: nesting limit is currently set to 127

"###;

Expand Down Expand Up @@ -2796,16 +2796,69 @@ fn too_many_unclosed_loops() {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
loop {
";

let expected_diagnostic = r###"error: brace nesting limit reached
┌─ wgsl:65:13
65 │ loop {
│ ^ limit reached at this brace
= note: nesting limit is currently set to 64
┌─ wgsl:128:13
128 │ loop {
│ ^ limit reached at this brace
= note: nesting limit is currently set to 127

"###;

Expand Down