Skip to content

Conversation

@nathanmarks
Copy link
Contributor

Fixes missing source locations for ReturnStatement nodes in generated ast. Simple change using existing pattern, only required changes to the codegen step, no other pipeline changes.

Most file changes are new lines in generated code. First commit has the relevant changes, second commit has the noisy snap updates.

I added an exception to the validator to not report an error when a return statement will be optimized to an implicit return by codegen, as there's no separate return statement to instrument anyways in the final ast. An edge case when it comes to preserving source locations for instrumentation that is likely not as common for most babel transforms since they are not doing optimizations.

@meta-cla meta-cla bot added the CLA Signed label Jan 29, 2026
@nathanmarks nathanmarks force-pushed the nathanmarks/fix-compiler-return-sourcelocs branch from c80cc4f to 7cce478 Compare January 29, 2026 20:04
@nathanmarks nathanmarks marked this pull request as ready for review January 29, 2026 20:34
Copy link
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

@josephsavona josephsavona merged commit 64b4605 into facebook:main Jan 30, 2026
21 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 30, 2026
Fixes missing source locations for ReturnStatement nodes in generated
ast. Simple change using existing pattern, only required changes to the
codegen step, no other pipeline changes.

**Most file changes are new lines in generated code.** [First
commit](d15e90e)
has the relevant changes, second commit has the noisy snap updates.

I added an exception to the validator to not report an error when a
return statement will be optimized to an implicit return by codegen, as
there's no separate return statement to instrument anyways in the final
ast. An edge case when it comes to preserving source locations for
instrumentation that is likely not as common for most babel transforms
since they are not doing optimizations.

DiffTrain build for [64b4605](64b4605)
github-actions bot pushed a commit that referenced this pull request Jan 30, 2026
Fixes missing source locations for ReturnStatement nodes in generated
ast. Simple change using existing pattern, only required changes to the
codegen step, no other pipeline changes.

**Most file changes are new lines in generated code.** [First
commit](d15e90e)
has the relevant changes, second commit has the noisy snap updates.

I added an exception to the validator to not report an error when a
return statement will be optimized to an implicit return by codegen, as
there's no separate return statement to instrument anyways in the final
ast. An edge case when it comes to preserving source locations for
instrumentation that is likely not as common for most babel transforms
since they are not doing optimizations.

DiffTrain build for [64b4605](64b4605)
@nathanmarks nathanmarks deleted the nathanmarks/fix-compiler-return-sourcelocs branch January 30, 2026 17:32
github-actions bot pushed a commit to code/lib-react that referenced this pull request Feb 2, 2026
Fixes missing source locations for ReturnStatement nodes in generated
ast. Simple change using existing pattern, only required changes to the
codegen step, no other pipeline changes.

**Most file changes are new lines in generated code.** [First
commit](facebook@d15e90e)
has the relevant changes, second commit has the noisy snap updates.

I added an exception to the validator to not report an error when a
return statement will be optimized to an implicit return by codegen, as
there's no separate return statement to instrument anyways in the final
ast. An edge case when it comes to preserving source locations for
instrumentation that is likely not as common for most babel transforms
since they are not doing optimizations.

DiffTrain build for [64b4605](facebook@64b4605)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Feb 2, 2026
Fixes missing source locations for ReturnStatement nodes in generated
ast. Simple change using existing pattern, only required changes to the
codegen step, no other pipeline changes.

**Most file changes are new lines in generated code.** [First
commit](facebook@d15e90e)
has the relevant changes, second commit has the noisy snap updates.

I added an exception to the validator to not report an error when a
return statement will be optimized to an implicit return by codegen, as
there's no separate return statement to instrument anyways in the final
ast. An edge case when it comes to preserving source locations for
instrumentation that is likely not as common for most babel transforms
since they are not doing optimizations.

DiffTrain build for [64b4605](facebook@64b4605)
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.

2 participants