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: Should not be a structural type system #5796

Open
stefnotch opened this issue Jun 10, 2024 · 1 comment
Open

Naga: Should not be a structural type system #5796

stefnotch opened this issue Jun 10, 2024 · 1 comment
Labels
area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator type: bug Something isn't working

Comments

@stefnotch
Copy link
Contributor

stefnotch commented Jun 10, 2024

Description
Currently naga will accept using a struct as another struct with the same layout.

Could it be that type checking only checks if the layout of a type is the same? And that aliases could be an issue, because they're represented as a copy of a given type in the naga::Module.

Repro steps

Add the following to naga/tests/wgsl_errors.rs. Naga creates a module and says it's valid, instead of throwing the expected error.

#[test]
fn different_types() {
    check_validation! {
        "@vertex
fn vtx_main() -> @builtin(position) vec4f {
  // I'm assigning a Foo to a Bar
  let x: Bar = Foo(1);
  return vec4f(f32(x.a));
}
 
struct Foo { a: u32 };
struct Bar { a: u32 }; // Same layout":
        Err(naga::valid::ValidationError::Type  {
            ..
        })
    }
}

Expected vs observed behavior
I expected it to match the Chrome behaviour of throwing an error.

Platform

  • Windows 11
  • WGSL trunk on commit 583cc6a (one of the latest commits)
@teoxoy teoxoy added type: bug Something isn't working area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator labels Jun 11, 2024
@teoxoy
Copy link
Member

teoxoy commented Jun 11, 2024

Thanks for filing! I thought we had an issue tracking this but I can't seem to find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants