Skip to content

Conversation

@andyleiserson
Copy link
Contributor

Fixes two issues with const evaluation of bitwise shifts:

  • Disallows mixed scalar/vector shifts (scalar << vector or vector << scalar), which should not be allowed.
  • Detects overflowing runtime << constant shifts at constant evaluation time.

Also includes, as a separate commit, cleanup of some noisy log messages in the naga expression validator.

Testing
Enables CTS tests.

Squash or Rebase? Rebase

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.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@teoxoy
Copy link
Member

teoxoy commented Jan 26, 2026

Looks like CI is unhappy.

@andyleiserson
Copy link
Contributor Author

The previous version was pretty broken (in that it would not raise the error in the cases it intended to) because the constant evaluator is only capable of resolving the type of constant expressions.

So I had to move the check to the validator. I also fixed handling of 64-bit shift operands and added some tests in wgsl_errors.

The substantive changes from the previous version are limited to the last commit.

fn check_error_matches(input: &str, expected_substring: &str) {
use std::borrow::Cow;
let input = if input.trim_start().starts_with("var ") {
Cow::from(format!("fn foo() {{ {} }}", input))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think doing this here is unexpected. If we need this abstracted, adding a separate function that does this would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably so. I removed it... when it comes at the overhead of an extra function call, it doesn't really feel like it's worth the characters it saves over writing fn foo() { } in each test case.

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.

2 participants