Skip to content

Confusing error due to mixup between WildcardType and TypeBounds #4421

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

Closed
Blaisorblade opened this issue Apr 30, 2018 · 2 comments
Closed

Confusing error due to mixup between WildcardType and TypeBounds #4421

Blaisorblade opened this issue Apr 30, 2018 · 2 comments
Assignees
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc area:typer

Comments

@Blaisorblade
Copy link
Contributor

After recent fixes, the following code doesn't crash but gives an error message worth improving:

scala> class A1 extends _
1 |class A1 extends _
  |                 ^
  |                  is not a class type

That error comes from ctx.error(ex"$tp is not a class type", pos), but $tp is being pretty-printed to the empty string. This happens because $tp is TypeBounds(q"Nothing", q"Any") (where q"Nothing" is just informal quasiquote notation) instead of being WildcardType(TypeBounds(q"Nothing", q"Any")), and such type bounds are correctly pretty-printed to the empty string.

@Blaisorblade Blaisorblade self-assigned this Apr 30, 2018
@Blaisorblade Blaisorblade added area:reporting Error reporting including formatting, implicit suggestions, etc area:typer labels Apr 30, 2018
@Blaisorblade Blaisorblade changed the title Confusing error Confusing error due to mixup between WildcardType and TypeBounds Apr 30, 2018
@smarter
Copy link
Member

smarter commented Apr 30, 2018

In that particular case, I think we should just emit an error about unbound wildcard in the parser, like for everything else in #4373

@odersky
Copy link
Contributor

odersky commented May 1, 2018

I actually think the error message is fine. The pointed to _ is indeed not a class type. Since this error is very unlikely to occur in the wild, I would not spend time and code lines to improve it.

@odersky odersky closed this as completed May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc area:typer
Projects
None yet
Development

No branches or pull requests

3 participants