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] Subtraction without spaces #1104

Closed
munrocket opened this issue Jul 17, 2021 · 4 comments
Closed

[wgsl-in] Subtraction without spaces #1104

munrocket opened this issue Jul 17, 2021 · 4 comments
Labels
area: front-end Input formats for conversion help wanted Extra attention is needed kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@munrocket
Copy link

This code gives an error

fn sub() -> f32 {
  return 4.-2.;
}

the same code with spaces or another operation +*/ is ok

fn sub() -> f32 {
  return 4.- 2.;
}

this bug little bit annoying for users because it is not easy to find it. I am used metal as an output but probably this kind of bug occur on other platforms, because it is related to parser.

@kvark kvark added area: front-end Input formats for conversion help wanted Extra attention is needed kind: bug Something isn't working lang: WGSL WebGPU shading language labels Jul 18, 2021
@hcsch
Copy link
Contributor

hcsch commented Aug 24, 2021

I believe this is currently how the spec intends it to be, based on the discussion in gpuweb/gpuweb#775. The spec considers the - as part of the number literals and those are greedily parsed, at least with the current version of the spec.
That means that as long as the spec doesn't change and naga wants to maintain its compliance, this is likely not actionable.

See also https://www.w3.org/TR/2021/WD-WGSL-20210823/#literals (the current version at the time of writing), which specifically mentions this issue in a note.

gpuweb/gpuweb#775 does show that this might change in the (perhaps even near) future, at least from what I'm reading in the more recent comments.

@munrocket
Copy link
Author

O_o

@munrocket
Copy link
Author

Chrome didn't follow this greedy parser rule. WGSL shaders works as expected.
@hcsch we just can fix it in naga and improve specification (specially when it with TODO addition).

@munrocket munrocket reopened this Aug 25, 2021
@jimblandy
Copy link
Member

This is per spec, but considered a bug in the spec. I explained the current plans to fix the spec over here. When the spec is fixed, we'll create a new issue for that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end Input formats for conversion help wanted Extra attention is needed kind: bug Something isn't working lang: WGSL WebGPU shading language
Projects
None yet
Development

No branches or pull requests

4 participants