-
Notifications
You must be signed in to change notification settings - Fork 344
Closed
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues
Milestone
Description
We'd like to reconsider part of #3813
We'd like to disallow the a statement whose top-level thing is a type-constructor expression.
Example:
struct S { a: i32 }
fn foo_bad() {
i32(); // This parses, but we should disallow this.
S(15); // This parses, but we should disallow this.
42; // Already disallowed; this doesn't even parse in the first place.
}
A type-constructor does not have side effects (once you've evaluated its arguments). So there is no use for it.
If you really want to evaluate a type constructor, then use a phone assignment, even though that is silly: _ = i32();
We do explicitly allow function calls as statements. The desirable use case is to capture the side effects, like this:
var<workgroup> p: i32;
fn foo_ok() {
workgroupBarrier(); // allowed
atomicStore(&p, 0); // allowed
my_helper_does_something(); // allowed, whether or not the helper returns a value.
}
Metadata
Metadata
Assignees
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues