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

[naga] Disallow logical operators && and || on vectors #7368

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

andyleiserson
Copy link
Contributor

@andyleiserson andyleiserson commented Mar 18, 2025

Connections
Fixes #6856

Description
This change disallows the logical operators && and || on vectors, which WGSL does not allow. There are two relevant codepaths, one for constant evaluation and one for type checking of expressions to be evaluated at runtime.

I tested this change locally in combination with #7339. The two changes actually do not conflict and interact minimally. In #7339, I implemented a transformation while lowering to IR that gets applied only if the operands have a correct (scalar) type. If the operands are not scalars, the expression is passed through with the expectation that validation rejects it. This change affects what will ultimately pass validation.

Arguably, these operators should be removed from the Naga IR entirely. I have not done that, because the BinaryOperator enum is shared by the AST and IR representations.

Testing
Added tests in wgsl_errors to verify both operators are rejected in both const and runtime contexts.

Squash or Rebase? Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • Add a CHANGELOG.md entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Naga wgsl-in allows vecN<bool> && vecN<bool> (with 2 &s) but Chromium/dawn doesn't
2 participants