WGSL precedence parsing is too lenient #4536
Labels
area: naga front-end
lang: WGSL
WebGPU Shading Language
naga
Shader Translator
type: bug
Something isn't working
Milestone
Per gpuweb/gpuweb#3346, WGSL has a partial order of precedence, meaning that among other things the arguments to a shift expression must be parenthesized if they are not unary:
a + b << c
is not valid and should not parse (in C precedence rules, this would be(a + b) << c
which is very likely not what's intended, hence the nudge to always explicitly parenthesize).Looking at the code this should be fairly straightforward. From what I can see,
parse_equality_expression
currently nests the additive_expression parser inside a call toparse_binary_op
for shift_expression, and this should be changed to more closely match the structure of the WGSL spec.The text was updated successfully, but these errors were encountered: