Skip to content

Naga: Should not be a structural type system #5796

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

Closed
stefnotch opened this issue Jun 10, 2024 · 1 comment · Fixed by #7444
Closed

Naga: Should not be a structural type system #5796

stefnotch opened this issue Jun 10, 2024 · 1 comment · Fixed by #7444
Assignees
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.

@andyleiserson andyleiserson self-assigned this Mar 28, 2025
andyleiserson added a commit to andyleiserson/wgpu that referenced this issue Mar 28, 2025
andyleiserson added a commit to andyleiserson/wgpu that referenced this issue Mar 28, 2025
@andyleiserson andyleiserson moved this from Todo to In Progress in WebGPU for Firefox Mar 28, 2025
andyleiserson added a commit to andyleiserson/wgpu that referenced this issue Apr 10, 2025
andyleiserson added a commit to andyleiserson/wgpu that referenced this issue Apr 10, 2025
@teoxoy teoxoy closed this as completed in 2a2c851 Apr 10, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in WebGPU for Firefox Apr 10, 2025
Vecvec pushed a commit to Vecvec/wgpu that referenced this issue Apr 10, 2025
Vecvec pushed a commit to Vecvec/wgpu that referenced this issue Apr 11, 2025
jimblandy pushed a commit to jimblandy/wgpu that referenced this issue Apr 18, 2025
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
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants