Use LHS of ref-assignment for ref-readonly#24904
Use LHS of ref-assignment for ref-readonly#24904agocke merged 1 commit intodotnet:features/ref-reassignmentfrom
Conversation
There was a problem hiding this comment.
I would just call CheckValueKind on the left recursively.
There are other value kinds such as "ref-returnable". Lets just defer all checks to the LHS. - for the same reason we would want to defer writeability.
Will need a test for "ref-returnable", I guess.
There was a problem hiding this comment.
But there's no recursion here, is there? A ref assignment must have a variable on the left hand, so this can't go any deeper than one level. This also may make error production worse because CheckValueKind would produce an error on the LHS of the assignment, even though there's nothing wrong with the LHS here, only the expression as a whole.
There was a problem hiding this comment.
I guess we are duplicating code here by checking the readonlyness in two places. I'll call CheckValueKind.
8f087d1 to
25a5185
Compare
|
@dotnet-bot test windows_release_unit64_prtest please |
|
ping @dotnet/roslyn-compiler for one more review |
|
ping @dotnet/roslyn-compiler |
1 similar comment
|
ping @dotnet/roslyn-compiler |
There was a problem hiding this comment.
return [](start = 20, length = 6)
Nit: should have empty line after }
64f67df to
6663476
Compare
The spec for ref-reassignment is that the LHS of the ref-reassignment expression is the ref-readonlyness of the LValue produced by the expression. That is, if the LHS of a ref assignment is readonly, the resulting LValue is as well. This PR also fixes a related issue for ref-like assignments, where the resulting lifetime of the assignment was decided based on the RHS, instead of the LHS. Fixes dotnet#24874
6663476 to
5c47a8c
Compare
The spec for ref-reassignment is that the LHS of the ref-reassignment
expression is the ref-readonlyness of the LValue produced by the
expression. That is, if the LHS of a ref assignment is readonly, the
resulting LValue is as well.
This PR also fixes a related issue for ref-like assignments, where the
resulting lifetime of the assignment was decided based on the RHS,
instead of the LHS.
Fixes #24874