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

Add -1 for any diagnostics using point() in Scala 3 #386

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Sep 14, 2020

This came up in case of ambigous implicits:

-- Error: dotty-interpolation.scala:23:15 --------------------------------------
23 |    val xx = fn    
   |               ^
   |ambiguous implicit arguments: both object c1 in class App and object c2 in class App match type App.this.C of parameter c of method fn in class App

diagnostic seems to be pointing to the place the parameters are supposed to be, which is not a real position. We need to do -1 in those cases, though not 100% sure it will work in every situation, but we can fix it as we find more issues.

Copy link
Contributor

@kpbochenek kpbochenek left a comment

Choose a reason for hiding this comment

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

just minor comments not even directly related to your changes, ignore if you want :)

fix LGTM 👍

@@ -166,7 +166,7 @@ class MarkdownCompiler(
case (Right(start), Right(end)) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

pos: SourcePosition <- will never be optional

Copy link
Contributor

Choose a reason for hiding this comment

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

(comment not related to this line but parameter of this method)

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 have not noticed! Thanks and fixed!

@@ -166,7 +166,7 @@ class MarkdownCompiler(
case (Right(start), Right(end)) =>
Position.Range(start.input, start.start, end.end).toUnslicedPosition
Copy link
Contributor

Choose a reason for hiding this comment

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

val position = pos.get <- never used (not related to this exact line)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right! Fixed together with the previous one.

@@ -329,6 +329,23 @@ class WorksheetSuite extends BaseSuite {
|""".stripMargin
)

checkDiagnostics(
"dotty-interpolation".tag(OnlyScala3),
Copy link
Contributor

Choose a reason for hiding this comment

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

rename test, one above is called the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@tgodzik tgodzik force-pushed the fix-wrong-error-pos branch from 32d4738 to c5ae028 Compare September 14, 2020 18:54
@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 18, 2020

I will go ahead and merge. Might not be the best possible solution, but it fixes it for now and might not be an issue in the long run. I think point will mostly be needed to be used in cases when diagnostic is reported after a symbol. Alternative approach would be to modify edit distance to try to catch previous token if the one at the current position does not exist, but that would also change the bahaviour for Scala 2, which I don't want to currently do as the Scala 3 approach might still evolve.

@tgodzik tgodzik merged commit d9ac112 into scalameta:master Sep 18, 2020
@tgodzik tgodzik deleted the fix-wrong-error-pos branch September 18, 2020 11:44
@tgodzik tgodzik mentioned this pull request Apr 12, 2021
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