Skip to content

Fix span of simple enum cases #6748

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
Jun 27, 2019
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 26, 2019

The span should start with the enum case itself, not the preceding case keyword.
This matters if there are many cases in a list.

We got a crash when converting ErrorMessageID to Scala since the spans were longer than where a nameSpan could be recorded. This led to crash due to a duplicate position when registering a child.

odersky added 2 commits June 26, 2019 13:34
The span should start with the enum case itself, not the preceding `case` keyword.
This matters is there are many cases in a list.
Even with the fix to enum spans, we could still get a case where
a point to a name is missing (maybe because there is a long comment
between the start of the definition and the name). The current fix
makes the computation succeed more often, but it is not perfect.
val nameStart =
if (point != span.start) point
else {
// Point might be too far away from start to be recorded. In this case we fall back to scanning
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a test case that exercises this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original test case was ErrorMessagesID, and I verified that the change here works for it. But c8265f1 fixes the problem by another means, so it's no longer a test case.

@odersky odersky merged commit 8b1e36a into scala:master Jun 27, 2019
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.

3 participants