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

WGSL: Cannot alias u32, vec3f, and other previously reserved words #5786

Open
stefnotch opened this issue Jun 9, 2024 · 2 comments
Open
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working

Comments

@stefnotch
Copy link
Contributor

Description

u32, vec3f and other types are no longer reserved keywords in WGSL. They're predeclared types.

So aliasing them should be valid, even if very odd.

Repro steps
Add the following test to naga\src\front\wgsl\tests.rs

#[test]
fn parse_alias_builtin() {
    parse_str(
        "
        alias u32 = i32;
        alias vec2f = vec3f;
        fn main1() {
            var x: u32 = -1i;
            var y: vec2f = vec3<f32>(1.0, 2.0, 3.0);
        }
    ",
    )
    .unwrap();

    parse_str(
        "
        alias u32 = i32;
        alias vec2f = vec3f;
        struct Foo { x: u32, y: vec2f }
        fn main() {
            var x: Foo = Foo(-1i, vec3<f32>(1.0, 2.0, 3.0));
        }
    ",
    )
    .unwrap();
}

Expected vs observed behavior
I expected the shaders to compile. Actual behaviour is that it fails with

thread 'front::wgsl::tests::parse_alias_builtin' panicked at naga\src\front\wgsl\tests.rs:150:6:
called `Result::unwrap()` on an `Err` value: ParseError { message: "name `u32` is a reserved keyword", labels: [(Span { start: 15, end: 18 }, "definition of `u32`")], notes: [] }

Extra materials
This may be related to #4473 ?

Platform

  • Windows 11
  • WGSL trunk on commit 583cc6a (one of the latest commits)
@teoxoy
Copy link
Member

teoxoy commented Jun 10, 2024

#4406 should cover this but we can keep this open as I'm not sure what's left to do and this seems like a subtask.

@teoxoy teoxoy added type: bug Something isn't working naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language labels Jun 10, 2024
@stefnotch
Copy link
Contributor Author

Good to know that this is a duplicate of an existing issue, thank you for finding it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants