-
Notifications
You must be signed in to change notification settings - Fork 353
Assignable expression #1549
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
Assignable expression #1549
Conversation
| Otherwise, singular expression is a pointer expression in an Assigning (L-value) context | ||
| which maps to OpAccessChain followed by OpStore | ||
|
|
||
| assignment_statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already an assignment_statement production
Does this PR mean to add to it, or replace it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github diff showing it in a weird way, but hey, it's just 6 lines!
The PR only changes the assignment_statement, doesn't add a new one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I don't think this approach scales. The assignment statement is a store of a value to storage in memory. The thing on the RHS is the thing you store. It has a type (which must be "storable", as defined in the spec). The thing on the LHS is a reference to storage with a particular store type. The store type of the LHS must be the same as the type on the RHS. The cleanest way is to define types that denote a view into locations in a particular storage class, such that you can store a value of a particular store type. |
kvark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this approach scales.
Could you elaborate please? What does it need to scale to?
The store type of the LHS must be the same as the type on the RHS.
So type checking is going to get involved somehow.
Yes, precisely in the way you described. We'd just say that the type on the left has to match the type on the right.
Separately, we'd say that the IDENT on the LHS has to be pointing to a store-able variable.
This seems much easier than to go into the whole ref territory with implicit coersions.
| Otherwise, singular expression is a pointer expression in an Assigning (L-value) context | ||
| which maps to OpAccessChain followed by OpStore | ||
|
|
||
| assignment_statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github diff showing it in a weird way, but hey, it's just 6 lines!
The PR only changes the assignment_statement, doesn't add a new one
dneto0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blocks progress on other consensus items.
| Otherwise, singular expression is a pointer expression in an Assigning (L-value) context | ||
| which maps to OpAccessChain followed by OpStore | ||
|
|
||
| assignment_statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@dneto0 could you clarify on how this is blocking? |
|
#1569 has landed. Suggest we close this. |
* Inter stage validations * max components fix * max shader variable location and fixes * fix * fix
This is a follow-up to #1456, on the topic of the type system reach with regards to references. This mini-proposal is developed in collaboration with
the white wolf@jimblandy.Basically, we all want WGSL to be able to statically check that the left side of the assignment statement is assignable. The disagreement is about what part of a static check is responsible for this. We can consider at least 3 different places for this:
This PR shows how we can get the static check with (1) + (3): grammar would ensure specific form of the left-hand expression, and the validation rules would check for mutability (i.e. is the
IDENTreally aconstor a uniform buffer?). The proposal excludes pointers (since the pointers spec still needs to land either way, it's incomplete right now). I think it looks very simple and approachable.The benefit of going this route is that the type system would not need to have any implicit coersions (from references to values on the right hand side).