Fix incorrect spans assigned in some cases#469
Merged
sjrd merged 1 commit intoMay 7, 2026
Conversation
sjrd
reviewed
May 7, 2026
Contributor
sjrd
left a comment
There was a problem hiding this comment.
Very nice. Thank you. I have some comments.
| * positions that goes wild. | ||
| */ | ||
| """type AbstractType | ||
| | type AbstractWithBounds >: Null <: Product""".stripMargin, |
Contributor
There was a problem hiding this comment.
I find it suspicious that this item disappears, instead of being fixed. Same thing below. Could you explain why that happens?
Author
There was a problem hiding this comment.
I think it's because of the !pos.isZeroExtent check here:
https://github.com/scalacenter/tasty-query/blob/main/tasty-query/shared/src/test/scala/tastyquery/PositionSuite.scala#L27
The type has no bounds, so the returned string is empty. If I remove that check, I get this error:
==> X tastyquery.PositionSuite.type-definition-tree-1 0.011s munit.ComparisonFailException: /home/jpeterson/lucid/tasty-query/tasty-query/shared/src/test/scala/tastyquery/PositionSuite.scala:404
403: )
404: )
405: }
values are not the same
=> Obtained
List(
"Int",
"",
">: Null <: Product",
"Int",
"Null <: Product = Null",
"Null <: Product"
)
=> Diff (- obtained, + expected)
"Int",
- "",
">: Null <: Product",
at munit.Assertions.failComparison(Assertions.scala:278)
24761ee to
01eeb11
Compare
sjrd
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've observed tasty-query occasionally reading the wrong position for certain trees.
Consider this example:
Here, the compiler inserts an inferred type annotation, so in TASTy, the
ValDefstatement looks like this:The
scala.Inttype annotation should have a zero-width span because it doesn't exist in the source text, but tasty-query incorrectly reads its span as the same as that ofid(42). Also, thescala.Inttype argument should have the same span as the function it's applied to (id), but it's instead the same as that of the entire function call (id(42)).This PR fixes both of these issues. I've verified that the tests I added fail before the fix, and succeed after the fix.