Skip to content

[compiler] Fix VariableDeclarator source location#35129

Merged
mofeiZ merged 8 commits intofacebook:mainfrom
nathanmarks:nathanmarks/compiler-fix-var-dec-source-loc
Dec 11, 2025
Merged

[compiler] Fix VariableDeclarator source location#35129
mofeiZ merged 8 commits intofacebook:mainfrom
nathanmarks:nathanmarks/compiler-fix-var-dec-source-loc

Conversation

@nathanmarks
Copy link
Contributor

@nathanmarks nathanmarks commented Nov 13, 2025

What

Fixes source locations for VariableDeclarator in the generated AST. Fixes a number of the errors in the snapshot I added yesterday in the source loc validator PR #35109

I'm not entirely sure why, but a side effect of the fix has resulted in a ton of snaps needing updating, with some empty lines no longer present in the generated output. I broke the change up into 2 separate commits. The first commit has the core change and the update to the missing source locations test expectation, and the second commit has the rest of the snapshot updates.

How

  • Add location for variable declarators in ast codegen.
    • We don't actually have the location preserved in HIR, since when we lower the declarations we pass through the location for the VariableDeclaration. Since VariableDeclarator is just a container for each of the assignments, the start of the id and end of the init can be used to accurately reconstruct it when generating the AST.
  • Add source locations for object/array patterns for destructuring assignment source location support

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants