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 wgsl-in] Add directive keywords to "expected" values on global item parsing #6421

Open
ErichDonGubler opened this issue Oct 17, 2024 · 1 comment
Labels
area: naga front-end good first issue Good for newcomers lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working

Comments

@ErichDonGubler
Copy link
Member

Is your feature request related to a problem? Please describe.

#6352 adds/added parsing for directives, which only happen before global declarations. However, it did not add any diagnostic adjustments for the final, fatal diagnostic presented when Naga simply did not find any sentinel tokens indicating a deeper parse path to try than Parser::global_decl. To be painfully concrete, I'm referring to the code here:

ExpectedToken::GlobalItem => concat!(
"global item ('struct', 'const', 'var', 'alias', ';', 'fn') ",
"or the end of the file"
)

Describe the solution you'd like

We should also suggest directive identifiers in the set of sentinels that begin a global item for this diagnostic.

Describe alternatives you've considered

We could simply not do this. However, this feels like hiding functionality in a way that hurts, rather than helps, users.

Additional context

-

@ErichDonGubler ErichDonGubler added type: bug Something isn't working naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language labels Oct 17, 2024
@jimblandy jimblandy changed the title Add directives to set of expected values in unexpected-expected error for global items [naga wgsl-in] Improve diagnostics for directives that appear in the wrong place Nov 6, 2024
@ErichDonGubler ErichDonGubler added the good first issue Good for newcomers label Nov 6, 2024
@jimblandy
Copy link
Member

This just a matter of extending the list of tokens in the error message to cover what's actually permitted.

@ErichDonGubler ErichDonGubler changed the title [naga wgsl-in] Improve diagnostics for directives that appear in the wrong place [naga wgsl-in] Add directive keywords to "expected" values on global item parsing Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end good first issue Good for newcomers lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants