Skip to content

Fix error position and msg for expression expected #5693

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 2 commits into from
Jan 16, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 10, 2019

No description provided.

@odersky odersky requested a review from olafurpg January 10, 2019 20:56
@olafurpg
Copy link
Contributor

I just tried locally and it's a nice improvement. One minor suggestion, you might want to shift the offset to the character before the newline.

screenshot 2019-01-11 at 10 11 19

When the range encloses a newline the red squiggle appears on multiple lines.

Would it make sense to apply this change for patterns?

screenshot 2019-01-11 at 09 58 14

Also, the error is different for types but I'm not sure how big of a change it would require to make it consistent with patterns and expressions.

screenshot 2019-01-11 at 10 03 11

 1. Indicate error after last token only if it appears on line
    before current token
 2. Apply the same scheme to missing patterns

I tried to apply it to missing types as well, but there it is not so easy.
I got follow-up errors that I would not get with the existing scheme. So
in summary it's not clear that the change for types would be worth it.
Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍

def expectedOffset: Int = {
val current = sourcePos(in.offset)
val last = sourcePos(in.lastOffset)
if (current.line != last.line) in.lastOffset else in.offset
Copy link
Contributor

Choose a reason for hiding this comment

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

I experienced two weird behaviors in vscode related to zero-length diagnostics microsoft/vscode#66482 and end-of-line diagnostics microsoft/vscode#66481 making the current diagnostics render like this

screenshot 2019-01-14 at 16 37 01

I was hoping they would render like this instead

screenshot 2019-01-14 at 14 48 01

It might be worth reverting the special handling of end-of-line diagnostics, but I'm not sure.

@odersky odersky merged commit 2b36ef9 into scala:master Jan 16, 2019
@allanrenucci allanrenucci deleted the fix-errpos branch January 16, 2019 09:01
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.

2 participants