-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Confusing compiler errors when you forget the using
keyword in given bar(using foo)
#19402
Labels
area:parser
area:reporting
Error reporting including formatting, implicit suggestions, etc
better-errors
Issues concerned with improving confusing/unhelpful diagnostic messages
itype:enhancement
Comments
raquo
added
area:reporting
Error reporting including formatting, implicit suggestions, etc
better-errors
Issues concerned with improving confusing/unhelpful diagnostic messages
itype:enhancement
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
Jan 9, 2024
nicolasstucki
added
area:parser
Spree
Suitable for a future Spree
and removed
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
Jan 9, 2024
i10416
added a commit
to i10416/dotty
that referenced
this issue
Jan 20, 2024
`given`-s can't have non-implicit arguments, but when users forget adding a `using` 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 have `using` modifier with clear reason, but `in.token == LPAREN && in.lookahead.isIdent(nme.using)` in Parsers.scala was too strict to delegate parameter clause handling to `termParamClauses`. 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 be `given`" error.
nicolasstucki
added a commit
that referenced
this issue
Feb 20, 2024
WojciechMazur
pushed a commit
that referenced
this issue
Jul 1, 2024
…g keyword [Cherry-picked 300f2cc]
WojciechMazur
pushed a commit
that referenced
this issue
Jul 2, 2024
…g keyword [Cherry-picked 300f2cc]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:parser
area:reporting
Error reporting including formatting, implicit suggestions, etc
better-errors
Issues concerned with improving confusing/unhelpful diagnostic messages
itype:enhancement
Compiler version
3.3.1, 3.4.0-RC1
Minimized example
Output Error/Warning message
Why this Error/Warning was not helpful
I intended to write
given bar(using foo: Foo): Bar = Bar(foo)
but forgot theusing
keyword.If I wasn't already familiar with these errors it would be hard to figure out what's wrong. The second error can be quite misleading if you don't pay attention to the reason ("only classes can have declared but undefined members"). And it's too easy to dismiss that reason because my
given
does appear to have a defined body.Suggested improvement
Ideally I expect an error saying that
given
-s can't have non-implicit arguments, and that I need ausing
keyword. Or anything that comes closer to that than the status quo really.The text was updated successfully, but these errors were encountered: