sbt reporter: Don't crash with malformed positions #10250
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In https://github.com/Sciss/DottyScalaTestAssertCrash we get a crash
when trying to report a warning in RichNumberSuite.scala: the file
contains 284 characters and yet the
pos.point
of the error is atposition 8742, this line calls the scalatest
assert
macro so it seemsthat something is wrong with the way we compute positions in macros (or
could the macro have a bug?). It'd be good if we could find the root
cause of the problem but in any case being robust when reporting errors
is better than crashing.
FWIW, after fixing this on top of 3.0.0-M1 and recompiling the
problematic project I see the following the warning:
[warn] -- [E123] Syntax Warning: /home/smarter/opt/DottyScalaTestAssertCrash/src/test/scala/synth/RichNumberSuite.scala:9:6
[warn] 9 | assert(intInt1.isInstanceOf[Int], "found " + intInt1.getClass)
[warn] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] |The highlighted type test will always succeed since the scrutinee type (TermRef(NoPrefix,val x).show) is a subtype of Int
[warn] | This location contains code that was inlined from RichNumberSuite.scala:12
Which still looks a bit weird (showing a raw TermRef, mentioning that
the code was inlined from
RichNumberSuite.scala:12
even thought that'sjust the last line of a file which contains only a
}
.