Skip to content

Do not remap a scope local's JS name again - #126

Open
NullVoxPopuli-ai-agent wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/no-chained-scope-remap
Open

NullVoxPopuli-ai-agent wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/no-chained-scope-remap

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

If one scope local renames to the hbs name of another scope local, the wire format gets the wrong value or the build crashes. This PR fixes that.

precompileTemplate("{{a}}{{b}}", { strictMode: true, scope: () => ({ a: b, b: c }) });

↳ {{a}} resolves to c. It must resolve to b.

precompileTemplate("{{a}}{{b}}", { strictMode: true, scope: () => ({ a: b, b: a }) });

↳ RangeError: Maximum call stack size exceeded

Cause

remapAndBindIdentifiers replaces each hbs name in the compiler output with its JS name. Babel then visits the new identifier. If that JS name is also an hbs name in the same scope, the plugin remaps it again.

4.0.1 has this bug.

Fix

path.skip() after the replacement, so Babel does not visit the new identifier.

Tests

  • "does not chain renamed scope locals"
  • "swaps the names of two scope locals"

Both fail on main and pass with the fix. The full suite passes on the default ember-source, 6.4, 5.12 and 3.28 (the last two with NO_LEXICAL_THIS=true).

🤖 Generated with Claude Code

remapAndBindIdentifiers replaces an hbs name with its JS name, and Babel
then visits the new identifier. If that JS name is also an hbs name in
the same scope, the plugin remapped it a second time:

- `{ a: b, b: c }` made `{{a}}` resolve to `c` instead of `b`
- `{ a: b, b: a }` overflowed the stack

Skip the new identifier after the replacement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants