Skip to content

Conversation

@mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Sep 19, 2025

Summary:

Fixes: #53839

Codegen uses object propertyNames as variable names. This breaks if the same property names appears at multiple levels. Also breaks if a property is called payload as payload is a variable name already used.

Before the fix codegen could generate code like this:

payload.setProperty(runtime, "payload", payload);

Changelog:

[GENERAL] [FIXED] - Fix Codegen to use unique variable names to avoid name collisions in corner cases

Test Plan:

  • jest snapshot tests

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 19, 2025
@mfazekas mfazekas changed the title fix(codegen): use ${properyName}_${idx} pattern for naming variables to avoid using same variable for different properties fix(codegen): ensure unique c++ variable names to avoid collision for properties with the same name Sep 19, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 19, 2025
note89304214615-hue

This comment was marked as off-topic.

@javache
Copy link
Member

javache commented Nov 5, 2025

Thanks for the fix! Could we make this even more explicit by using variable names such as __codegen__location

@cortinico
Copy link
Contributor

Thanks for the fix! Could we make this even more explicit by using variable names such as __codegen__location

cc @mfazekas

@mfazekas
Copy link
Contributor Author

mfazekas commented Nov 17, 2025

Thanks for the fix! Could we make this even more explicit by using variable names such as __codegen__location

cc @mfazekas

Just to clarify if name is location right now should it be
__codegen__2__location

@mfazekas mfazekas force-pushed the mfazekas/fix-codegen-varnames branch from 796d4cb to 6ce639b Compare November 17, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codegen variable naming can result in incorrect code

5 participants