Skip to content

Conversation

@uniqueiniquity
Copy link
Contributor

While investigating #33935, one reported repro was found because it caused a classification to have negative length.
Here, we add an assertion so that the language service fails, rather than the client having to handle such a case.


function pushClassification(start: number, end: number, type: ClassificationType): void {
const length = end - start;
Debug.assert(length >= 0, `Classification had non-positive length of ${length}`);
Copy link
Member

@DanielRosenwasser DanielRosenwasser Oct 17, 2019

Choose a reason for hiding this comment

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

Slightly nervous about a 0-length span getting a classification unless we classify 0-length trivia...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. It seemed like some classification spans made sense to only have trivia (since node.getStart is the start used here) but I now see that those won't come up in this path.

@uniqueiniquity uniqueiniquity merged commit 1bfc472 into microsoft:master Oct 18, 2019
@uniqueiniquity uniqueiniquity deleted the classifcationAssertion branch October 18, 2019 16:44
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants