Fix split init of const variables and update lvalue errors #15800
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #15335
Related to #5068
Besides allowing split-init of const variables, this PR adjusts l-value
checking errors from resolution to give an error about constness instead
of one mentioning the term "lvalue" when that makes sense. This helps
with, but does not completely resolve, issue #5068.
Note that the future
https://github.com/chapel-lang/chapel/tree/master/test/variables/constants
has requested different wording for the lvalue error that talks about
const variables instead. This PR moves in that direction but it does not
completely remove the potential for getting an lvalue error. In
particular, something like the following example
still gives an error about lvalues.
The compiler change amounted to adjusting
isLegalLvalueActualArg
toreturn whether the error is from the argument being a call-expression
temporary or is from the argument being const. Then, used that to avoid
giving constness errors for
out
intent arguments at this time, becauselater parts of resolution might change them to split-init. Constness
errors for out intent will still be detected in late const checking.
Reviewed by @vasslitvinov - thanks!