Skip to content
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

wgsl switch spec grammar allows case default #2128

Closed
simonbuchan opened this issue Nov 18, 2022 · 0 comments · Fixed by #2126
Closed

wgsl switch spec grammar allows case default #2128

simonbuchan opened this issue Nov 18, 2022 · 0 comments · Fixed by #2126
Labels
area: front-end Input formats for conversion lang: WGSL WebGPU shading language type: enhancement

Comments

@simonbuchan
Copy link

C.f. https://www.w3.org/TR/WGSL/#switch-statement:

switch_statement :
| switch expression brace_left switch_body + brace_right

switch_body :
| case_clause

| default_alone_clause

case_clause :
| case case_selectors colon ? compound_statement

default_alone_clause :
| default colon ? compound_statement

case_selectors :
| case_selector ( comma case_selector ) * comma ?

case_selector :
| default

| expression

the body is a list of [switch_body]s, which can be either case [case_selectors] ... or default ..., but [case_selector] can also be default, meaning, if I'm reading this correctly, should allow both:

switch x {
  default { foo }
  case 1 { bar }
}

and

switch x {
  case default { foo }
  case 1 { bar }
}

but the latter on naga (0.10.0) gives something like:

Shader 'box.wgsl' parsing error: expected unsigned/signed integer literal, found 'default'
   ┌─ wgsl:60:12
   │
60 │       case default { uv.x = 0.0; }
   │            ^^^^^^^ expected unsigned/signed integer literal

    expected unsigned/signed integer literal, found 'default'
@teoxoy teoxoy added lang: WGSL WebGPU shading language area: front-end Input formats for conversion type: enhancement labels Nov 18, 2022
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end Input formats for conversion lang: WGSL WebGPU shading language type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants