-
-
Notifications
You must be signed in to change notification settings - Fork 371
Fix exception when printing some warnings #1706
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
Fix exception when printing some warnings #1706
Conversation
|
In more detail, we get the following in Scala 2.13 and the following in Scala 2.12 (different invalid array index) |
Not sure why, this warning's position is a RangePosition (with a start, an end, and a "point" that may lie outside of the [start,end] range), and its point value doesn't get offset by the LineNumberModifier plugin. This makes Position.formatError throw an ArrayIndexOutOfBoundException if we don't fix that point value ourselves.
84a5a34 to
13381bf
Compare
| def mvnDeps: T[Seq[Dep]] = super.mvnDeps() ++ amm.compiler().mvnDeps() ++ Seq( | ||
| Deps.scalazCore | ||
| Deps.scalazCore, | ||
| Deps.coursierVersions(scalaVersion()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this change is related to the position fix.
Can you help me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency is only added in the tests of the repl module. I use it to compare Scala versions (some test data is different up to 2.12.12 vs after it), rather than flaky hand made version comparison.
|
|
||
| def fixPos(pos: Position): Position = | ||
| pos match { | ||
| case r: RangePosition if r.point > r.source.length && r.point - importsLen >= 0 && r.point - importsLen <= r.source.length => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a hack. This substracts importsLen when it feels it's the right thing to do (point is higher than the source length, and offsetting importsLen from it brings it back into the source).
Not sure why, the position of the warning in the added test is a
RangePosition(with a start, an end, and a "point" that may lie outside of the [start,end] range), and its point value doesn't get offset by theLineNumberModifierplugin. This makesPosition.formatErrorthrow anIndexOutOfBoundsExceptionif we don't fix that point value ourselves.