Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[wgsl-in] Phony assignment #1842

Closed
hanawatson opened this issue Apr 16, 2022 · 3 comments · Fixed by #1866
Closed

[wgsl-in] Phony assignment #1842

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

Comments

@hanawatson
Copy link

Hi, phony assignments in WGSL input seem to not be recognised by naga currently

code example (slightly altered copy of an example in the spec https://gpuweb.github.io/gpuweb/wgsl/#phony-assignment-section, since as this is an example use it should presumably definitely work):

var <private> counter: i32;

fn increment_and_yield_previous() -> i32 {
	let previous = counter;
	counter = counter + 1;
	return previous;
}

@stage(compute) @workgroup_size(1)
fn compute_main(
) {
	_ = increment_and_yield_previous();
}

resultant error:

error: unknown local function `_`
   ┌─ phonytest.wgsl:12:2
   │
12 │     _ = increment_and_yield_previous();
   │     ^ unknown local function

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
Copy link
Member

teoxoy commented Apr 16, 2022

We currently allow the _ identifier for let and var assignments and this works like phony assignment but according to the spec (and this issue) we shouldn't require let/var since the _ is not supposed to be an identifier and therefore not able to be declared via let/var.

@stshine
Copy link
Contributor

stshine commented Apr 18, 2022

It is strange for phony assignment not requiring let.

@teoxoy
Copy link
Member

teoxoy commented Apr 18, 2022

@stshine see gpuweb/gpuweb#2127 for the reasons behind it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

3 participants