Skip to content

Fix #10082: show friendly error message related to type inference #10100

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

Merged
merged 1 commit into from
Oct 30, 2020

Conversation

liufengyun
Copy link
Contributor

@liufengyun liufengyun commented Oct 27, 2020

Fix #10082: show friendly error message related to type inference

@@ -509,6 +509,8 @@ trait Inferencing { this: Typer =>
// required: String
// val y: List[List[String]] = List(List(1))
val hasUnreportedErrors = state.reporter.hasUnreportedErrors
if hasUnreportedErrors then return tree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odersky Any reason we previously still instantiated some type variables when hasUnreportedErrors is true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see a reason.

@smarter smarter requested a review from odersky October 30, 2020 11:45
@smarter smarter assigned odersky and unassigned smarter Oct 30, 2020
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@@ -509,6 +509,8 @@ trait Inferencing { this: Typer =>
// required: String
// val y: List[List[String]] = List(List(1))
val hasUnreportedErrors = state.reporter.hasUnreportedErrors
if hasUnreportedErrors then return tree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see a reason.

@@ -509,6 +509,8 @@ trait Inferencing { this: Typer =>
// required: String
// val y: List[List[String]] = List(List(1))
val hasUnreportedErrors = state.reporter.hasUnreportedErrors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to define a local variable, it seems. We can simply return if state.reporter.hasUnreportedErrors is true.

@odersky odersky assigned liufengyun and unassigned odersky Oct 30, 2020
The type `site` in class `NotAMember` might be an uninitialized type variable,
but is initialized when we display the error message.
It results in confusing error message as in scala#10082.

We avoid instantiating the type variable when there is a unreported
error in current typerstate.
@liufengyun liufengyun merged commit a2b90ac into scala:master Oct 30, 2020
@liufengyun liufengyun deleted the fix-10082 branch October 30, 2020 18:47
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Value + is not a member of Int
4 participants