-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed as duplicate of#7225
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlyarea: naga front-endlang: WGSLWebGPU Shading LanguageWebGPU Shading Languagetype: bugSomething isn't workingSomething isn't working
Description
Description
Type conversions are not applied to switch selectors. Example (from https://math.hws.edu/graphicsbook/demos/c9/diffusion-demo.html, via https://bugzilla.mozilla.org/show_bug.cgi?id=1863457):
Shader '' parsing error: invalid switch value
┌─ wgsl:40:18
│
40 │ case 0 {
│ ^ expected unsigned integer
│
= note: suffix the integer with a `u`: `0u`
(The error message suggests but does not explicitly show that the selector has type u32
. I verified this to be the case.)
https://www.w3.org/TR/WGSL/#switch-statement says:
Type rule precondition: For a single switch statement, the selector expression and all case selector expressions must be of the same concrete integer scalar type.
and
The expressions in the case_selectors must be const-expressions.
This seems a bit underspecified, but we can probably do something reasonable.
Metadata
Metadata
Assignees
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlyarea: naga front-endlang: WGSLWebGPU Shading LanguageWebGPU Shading Languagetype: bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done