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-in] An 'expected one of ..' lexer error system would be nice #4329

Open
expenses opened this issue Apr 27, 2021 · 1 comment
Open

[wgsl-in] An 'expected one of ..' lexer error system would be nice #4329

expenses opened this issue Apr 27, 2021 · 1 comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: enhancement New feature or request

Comments

@expenses
Copy link
Contributor

With this wgsl code:

struct Foo {
  xxx: array<f32; 3>;
};
fn bar() -> Foo {
  return Foo(array<f32;3>(1.0, 2.0, 3.0));
}

we get the error:

error: expected paren, found `;`
  ┌─ wgsl:2:17
  │
2 │   xxx: array<f32; 3>;
  │                 ^ expected paren

thread 'main' panicked at 'unable to parse WGSL', bin/naga.rs:122:21

While a > parenthesis could go in that slot, a , comma could as well, which is the seperator between an array type and the number of items.
Ideally we'd have something like what rust does:

error: expected one of `>` `,`, found `;`
  ┌─ wgsl:2:17
  │
2 │   xxx: array<f32; 3>;
  │                 ^ expected one of `>` `,`

thread 'main' panicked at 'unable to parse WGSL', bin/naga.rs:122:21
@kvark
Copy link
Member

kvark commented Apr 27, 2021

I agree it would be great to be that precise, but it's a tough one to do. The expectations are sort of dynamic in the code, they depend on the implementation of a particular branch of logic...

@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@teoxoy teoxoy added type: enhancement New feature or request and removed kind: feature labels Jul 3, 2024
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: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants