Don't remap scope locals in non-reference positions - #120
Draft
NullVoxPopuli wants to merge 2 commits into
Draft
Conversation
NullVoxPopuli
marked this pull request as draft
August 12, 2026 16:22
NullVoxPopuli
force-pushed
the
no-remap-object-keys
branch
from
August 12, 2026 16:49
14edde9 to
0aa9cfb
Compare
NullVoxPopuli
force-pushed
the
no-remap-object-keys
branch
from
August 12, 2026 17:52
10da85d to
d39da4d
Compare
NullVoxPopuli
force-pushed
the
object-scope-test-coverage
branch
from
August 12, 2026 18:16
4a239b7 to
a5f9f6e
Compare
NullVoxPopuli
force-pushed
the
no-remap-object-keys
branch
from
August 12, 2026 18:18
ac86529 to
116f7d5
Compare
NullVoxPopuli
force-pushed
the
object-scope-test-coverage
branch
from
August 12, 2026 18:29
5ee859f to
176cf7c
Compare
`remapAndBindIdentifiers` rewrites a scope local's hbs name to its JS name
throughout the compiler's output, including in positions that aren't
references. Where the compiler emits an object-form scope, that renames the
property key too, so `{ Foo: Setup }` compiles to `scope: () => ({ Setup })`
and the name the template refers to is lost.
This passes against a compiler that emits the array-form scope, which has no
keys to lose, and fails against one that emits the object form — currently
ember-source 7, which the ember-latest and ember-beta try scenarios cover:
expected { Setup: 'Setup' } to deeply equal { Foo: 'Setup' }
The fix is in the next commit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`remapAndBindIdentifiers` rewrites a scope local's hbs name to its JS name throughout the template compiler's output, and it did so for every matching identifier, including ones that aren't references. Skip identifiers babel doesn't consider references, which fixes the property key case from the previous commit and covers the other non-reference positions an identifier can occupy. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NullVoxPopuli
force-pushed
the
no-remap-object-keys
branch
from
August 12, 2026 18:30
b3ce77e to
0e17675
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #121, which adds the
wireScopehelper this asserts with. Extracted from #117 so that PR can stay purely about literal scope values.remapAndBindIdentifiersrewrites a scope local's hbs name to its JS name throughout the template compiler's output, and it did so for every matching identifier — including ones that aren't references.That's fine while the wire format's scope is an array (
scope: () => [Setup]), because a local's name only ever appears in reference position. When the compiler emits the scope as an object — ember-source 7 does — the name also appears as a property key, and renaming it there drops the name the template refers to:The fix is to skip identifiers babel doesn't consider references (
path.isReferencedIdentifier()), which also covers the other non-reference positions an identifier can occupy.Commits
The first commit is intentionally red. It adds the test on its own, and because the bug only exists where the compiler emits keys, the failure lands in the try scenarios that run ember-source 7 —
ember-latestandember-beta, 7 legs in all, while every ember ≤6 leg passes:The second commit is the seven-line fix.
Worth noting:
package.jsonpinsember-sourceat^6.4.0-beta.1, so the primary Tests job doesn't exercise the object-form scope at all. Bumping that baseline to^7would put this coverage in the main job — the try scenarios already pin 3.28/4.12/5.12/6.4 explicitly, so nothing would lose coverage. Left out of this PR as a separate call.🤖 Generated with Claude Code