Skip to content

Check left side of an assignment expression for errors; fixes SI-9781#5179

Merged
adriaanm merged 1 commit intoscala:2.12.xfrom
liff:topic/SI-9781
May 24, 2016
Merged

Check left side of an assignment expression for errors; fixes SI-9781#5179
adriaanm merged 1 commit intoscala:2.12.xfrom
liff:topic/SI-9781

Conversation

@liff
Copy link
Contributor

@liff liff commented May 19, 2016

convertToAssignment is triggered on a type error but it doesn't seem to really care what the error is as long as the expression can be converted to an assignment expression.

This patch attempts to fix that by checking whether the left side of the expression contains any errors before deciding to continue with the conversion.

@scala-jenkins scala-jenkins added this to the 2.12.0-M5 milestone May 19, 2016
def onError(reportError: => Tree): Tree = fun match {
case Select(qual, name) if !mode.inPatternMode && nme.isOpAssignmentName(newTermName(name.decode)) =>
case Select(qual, name)
if !mode.inPatternMode && nme.isOpAssignmentName(newTermName(name.decode)) && !qual.exists(_.isErroneous) =>
Copy link
Member

Choose a reason for hiding this comment

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

I think it is sufficient to call qual.isErrorTyped, rather than traversing its components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that but it is not. In the test case, the Apply node itself has no error. The tree looks like:

Apply(Ident(TermName("c")), List(Ident(<TermName("undefinedSymbol"): error>)))

@retronym
Copy link
Member

retronym commented May 20, 2016

Could you please edit/expand the commit comment as:

SI-9781 Don't convert erroneous expression to assignment

`convertToAssignment` is triggered on a type error but it doesn't seem
to really care what the error is as long as the expression can be converted
to an assignment expression.

This patch fixes that by checking whether the qualifier of the selection
contains any errors before deciding to continue with the conversion.

@retronym retronym added the welcome hello new contributor! label May 20, 2016
`convertToAssignment` is triggered on a type error but it doesn't seem
to really care what the error is as long as the expression can be
converted to an assignment expression.

This patch fixes that by checking whether the qualifier of the selection
contains any errors before deciding to continue with the conversion.
@liff liff force-pushed the topic/SI-9781 branch from 9026142 to 6be9fc6 Compare May 20, 2016 04:55
@liff
Copy link
Contributor Author

liff commented May 20, 2016

Fixed commit comment.

@liff
Copy link
Contributor Author

liff commented May 23, 2016

/rebuild

@adriaanm adriaanm self-assigned this May 23, 2016
@adriaanm
Copy link
Contributor

LGTM -- thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

welcome hello new contributor!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants