-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Naga currently rejects programs with constant expressions such as this one:
const asdf = false && (123 / 0 > 0);An uninformed reader might assume that dividing by zero yielding an error is expected. Indeed, Naga will happily report an error here:
Could not parse WGSL:
error: Division by zero
┌─ in.wgsl:1:24
│
1 │ const asdf = false && (123 / 0 > 0);
│ ^^^^^^^ see msg
And yet, this is not standard behavior! The WGSL spec. clearly states that we should only be attempting const. eval. on the RHS of expressions when it cannot short-circuit. In the current WGSL spec.'s section 8.1.1:
The evaluation rule implies that short-circuiting operators
&&and||guard evaluation of their right-hand side subexpressions unless there is a subexpression that requires evaluation to determine a [static type](https://www.w3.org/TR/WGSL/#static-type).
Repro steps
Validate the above shader via naga as a file, i.e., in.wgsl. One can do this with a repo. checkout as follows:
$ cargo run -p naga-cli -- in.wgsl
Expected vs observed behavior
Already described, I hope!
Extra materials
Platform
Metadata
Metadata
Assignees
Labels
Type
Projects
Status