-
Notifications
You must be signed in to change notification settings - Fork 337
Open
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues
Milestone
Description
I think functions like this should be allowed:
fn f(a: i32) -> bool {
let a = true;
return a;
}
However, the spec says:
Two declarations in the same WGSL source program must not simultaneously:
introduce the same identifier name, and
have the same end-of-scope.
"§9.1. Declaring a User-defined Function" says:
The identifier is in scope until the end of the function.
"§6. Variable and Value Declarations" says:
The name is available for use in the statement immediately after its declaration until the end of the brace-delimited list of statements immediately enclosing the declaration.
These seem the same to me. They're definitely not clearly different.
I think this is uncontroversial, but here's why I think the code at top should be permitted:
- Shadowing is definitely permitted in inner blocks, so it seems consistent to permit it at the top-level block too.
- Such shadowing is permitted in many popular languages.
mehmetoguzderin and djgmehmetoguzderinmehmetoguzderinmehmetoguzderin
Metadata
Metadata
Assignees
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues