Skip to content

fix(50415): Language server debug failure - Did not expect GetAccessor to have an Identifier in its trivia - #50470

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 5 commits into
microsoft:mainfrom
a-tarasyuk:fix/50415
Aug 26, 2022
Merged

fix(50415): Language server debug failure - Did not expect GetAccessor to have an Identifier in its trivia#50470
Daniel Rosenwasser (DanielRosenwasser) merged 5 commits into
microsoft:mainfrom
a-tarasyuk:fix/50415

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #50415

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Aug 26, 2022

Copy link
Copy Markdown
Member

Can you amend the test case to test both orders of accessors as in

20432a6

and also clone the nodes for the set-accessor even if it's technically unnecessary?

b1358db

@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

and also clone the nodes for the set-accessor even if it's technically unnecessary?

Daniel Rosenwasser (@DanielRosenwasser) We need to clone nodes only for one of them - get or set. We have one copy of the properties applied to two methods simultaneously, which causes the error. Most of the props are new copies, so we just need to create new copies for one of them

const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName;
const visibilityModifier = createVisibilityModifier(declaration ? getEffectiveModifierFlags(declaration) : ModifierFlags.None);
const modifiers = visibilityModifier ? factory.createNodeArray([visibilityModifier]) : undefined;

@DanielRosenwasser

Copy link
Copy Markdown
Member

I understand that - I guess it doesn't entirely matter, but there are so many defensive copies all over the method other than in the updated section of code that I felt like it was probably better to be consistent than risk someone else glancing at the one place where we don't do a defensive copy.

If you're open to it, I was thinking of switching name, modifiers, and body to be local helper functions that generate unique deep clones for each usage. I'm not whether others would see it as an improvement.

@gabritto

Copy link
Copy Markdown
Member

Looks good to me, thanks. I don't really have an opinion on what Daniel suggested, so it's up to you and him.

@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

Gabriela Araujo Britto (@gabritto) I'll add updates

Comment thread src/compiler/factory/nodeFactory.ts
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) merged commit bb3a7ae into microsoft:main Aug 26, 2022
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language server debug failure - Did not expect GetAccessor to have an Identifier in its trivia

4 participants