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

Valid and Invalid declarations comment for built-in functions is a bit misleading #2934

Closed
dj2 opened this issue May 24, 2022 · 0 comments · Fixed by #3303
Closed

Valid and Invalid declarations comment for built-in functions is a bit misleading #2934

dj2 opened this issue May 24, 2022 · 0 comments · Fixed by #3303
Labels
copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.) wgsl:declarations wgsl WebGPU Shading Language Issues
Milestone

Comments

@dj2
Copy link
Member

dj2 commented May 24, 2022

In the Example: Valid and invalid Declarations we say:

// Invalid, cannot reuse built-in function names (modf in this case).
var<private> modf: f32 = 0.0;

According to the prose above:

Certain objects are provided by the WebGPU implementation, and are treated as if they have been declared by every WGSL program. We say such objects are predeclared. Their scope is the entire WGSL program.

The comment in the example implies you can never reuse a built-in function name. But, from the prose, the end scope of a built-in is the end of the module, so as long as I'm not at module scope I should be able to do:

fn foo() {
  var modf: f32 = 0.0;
}

and have that be valid and any references to modf would refer to the variable.

The first example should be updated to specify you cannot reuse at module scope and an example of re-using a built-in function name at function scope added to show it's allowed.

@dj2 dj2 added the wgsl WebGPU Shading Language Issues label May 24, 2022
@Kangz Kangz added this to the V1.0 milestone May 31, 2022
@kdashg kdashg added the copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.) label Jun 7, 2022
alan-baker added a commit to alan-baker/gpuweb that referenced this issue Aug 10, 2022
Fixes gpuweb#2933
Fixes gpuweb#2934

* Make Declaration and Scope into its own chapter
* Fix example about shadowing built-in function
  * add invalid example of using shadowed built-in function
* Add valid example of shadowed parameter
* Fix link for describing for scoping to right section
@dneto0 dneto0 closed this as completed in 3f247e6 Aug 10, 2022
jdarpinian pushed a commit to jdarpinian/gpuweb that referenced this issue Aug 12, 2022
Fixes gpuweb#2933
Fixes gpuweb#2934

* Make Declaration and Scope into its own chapter
* Fix example about shadowing built-in function
  * add invalid example of using shadowed built-in function
* Add valid example of shadowed parameter
* Fix link for describing for scoping to right section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.) wgsl:declarations wgsl WebGPU Shading Language Issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants