fix(#19402): error message for missing using in given params #19496
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.
close #19402
given
-s can't have non-implicit arguments, but when users forget adding ausing
modifier to given parameters, it showed unfriendly error message; "only classes can have declared but undefined members".The
termParamClauses
parser is aware of the owner of parameters and it raises a syntax error when parameters in given definition do not haveusing
modifier with clear reason, but the conditionin.token == LPAREN && in.lookahead.isIdent(nme.using)
in Parsers.scala was too strict to delegate parameter clause handling totermParamClauses
.Note:
This change requires tests/neg/i8150.check to be updated because the original test starts failing due to the syntax error rather than "refinement cannot be
given
" error.type T = {given A with A}
in i8150.check confirms that a valid given definition in RHS of type alias still raises the original error; "refinement cannot begiven
" error.