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] Numeric suffixes + unsanitised related error #1843

Closed
hanawatson opened this issue Apr 16, 2022 · 0 comments · Fixed by #1863
Closed

[wgsl-in] Numeric suffixes + unsanitised related error #1843

hanawatson opened this issue Apr 16, 2022 · 0 comments · Fixed by #1863
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@hanawatson
Copy link

Hi - I noticed that naga doesn't seem to correctly parse numeric suffixes (except for u for unsigned integers u32). According to the spec, WGSL theoretically also allows i (i32), f (f32) and h (f16, although f16 support/extension seems to be very new to the spec).

code example (analogous behavior for the i suffix and the f without exponent):

@stage(compute) @workgroup_size(1)
fn compute_main(
) {
	var var0: f32 = -2.9007446E38f;
}

resultant error:

error: expected ';', found 'f'
  ┌─ test.wgsl:6:31
  │
6 │     var var0: f32 = -2.9007446E38f;
  │                                  ^ expected ';'

Could not parse WGSL

Also (sorry to bombard you with issues!) - while checking the special 0x1f case just above this section of the spec https://gpuweb.github.io/gpuweb/wgsl/#keywords, I got an error that I suspect might not have been meant to be user-exposed.

code:

@stage(compute) @workgroup_size(1)
fn compute_main(
) {
	var var0: f32 = 0x1f;
}

error:

[2022-04-16T19:02:13Z ERROR naga::front::wgsl] Given type Scalar { kind: Float, width: 4 } doesn't match expected Scalar { kind: Sint, width: 4 }
error: the type of `var0` is expected to be `i32`
  ┌─ test1.wgsl:4:6
  │
4 │     var var0: f32 = 0x1f;
  │         ^^^^ definition of `var0`

Could not parse WGSL
@teoxoy teoxoy added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Apr 16, 2022
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Apr 30, 2022
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 kind: bug Something isn't working lang: WGSL WebGPU shading language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants