Skip to content
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

Unhelpful compiler error message with incompatible structural types #4877

Closed
scabug opened this issue Aug 6, 2011 · 2 comments
Closed

Unhelpful compiler error message with incompatible structural types #4877

scabug opened this issue Aug 6, 2011 · 2 comments
Assignees
Labels

Comments

@scabug
Copy link

@scabug scabug commented Aug 6, 2011

scala> def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
<console>:7: error: type mismatch;
 found   : java.lang.Object{}
 required: AnyRef{def bar: String}
       def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
                                           ^

It looks a bit like as if the compiler error message would use the erasure of the right expression return type. I would have expected something like:

scala> def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
<console>:7: error: type mismatch;
 found   : AnyRef{def bar: Int}
 required: AnyRef{def bar: String}
       def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
                                                                ^

The caret positioning could also be a bit better if it pointed to the def bar.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 6, 2011

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 6, 2011

Commit Message Bot (anonymous) said:
(extempore in r25456) Improved structural type error messages, and other error message
related boosts. Closes #4877, review by odersky.

@scabug scabug closed this Aug 6, 2011
@scabug scabug added the usability label Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.