Add assertion when classification has unexpected length#33938
Merged
uniqueiniquity merged 2 commits intomicrosoft:masterfrom Oct 18, 2019
Merged
Add assertion when classification has unexpected length#33938uniqueiniquity merged 2 commits intomicrosoft:masterfrom
uniqueiniquity merged 2 commits intomicrosoft:masterfrom
Conversation
sandersn
approved these changes
Oct 17, 2019
andrewbranch
approved these changes
Oct 17, 2019
|
|
||
| function pushClassification(start: number, end: number, type: ClassificationType): void { | ||
| const length = end - start; | ||
| Debug.assert(length >= 0, `Classification had non-positive length of ${length}`); |
Member
There was a problem hiding this comment.
Slightly nervous about a 0-length span getting a classification unless we classify 0-length trivia...
Contributor
Author
There was a problem hiding this comment.
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.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.