Skip to content

Comments

Fixed a class member completion crash after JSDoc comment with degenerate JSDoc tag in it#2888

Open
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/completion-class-member-at-rule-crash
Open

Fixed a class member completion crash after JSDoc comment with degenerate JSDoc tag in it#2888
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/completion-class-member-at-rule-crash

Conversation

@Andarist
Copy link
Contributor

fixes the crash reported here: #2871 (comment)
it also crashes in Strada

Comment on lines +582 to +585
result := find(rightmostValidNode, endPos)
if result == nil && n != containingNode {
return n
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, the JSDoc comment contains a degenerate JSDocTag with 0-width (representing "@-rule") - given @tag requires an identifier and - isn't a valid identifier character.

This matches how Strada parses the same case. But it creates an issue because the compiler fails to find contextToken. A nil from here just propagates up and later on it crashes in the completion code.

Copy link
Member

Choose a reason for hiding this comment

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

This looks ok if we don't want to change the parsing, but I do wonder if maybe that's what we should do (even though we had this problem in Strada, too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It crossed my mind to attempt a change there but I decided to err on the side of Strada compatibility for now. If you think the parsing should be changed instead, then I could start exploring that option.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's worth trying to fix it during parsing, yes. Given this would be a change in JSDoc invalid tag parsing, I don't think it's likely it would break people.

Items: &fourslash.CompletionsExpectedItems{
Includes: []fourslash.CompletionsExpectedItem{}, // no crash check
},
Items: &fourslash.CompletionsExpectedItems{},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a driveby change, I just corrected here one of the recent tests I added to use the more common codebase pattern

Copy link
Member

@gabritto gabritto left a comment

Choose a reason for hiding this comment

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

(see comment on fixing the tag parsing)

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.

2 participants