Commit 571a94d
Revert PathExpression legacy-upgrade in convertLocations
The previous commit (83ccd8d) tried to address a review comment by
upgrading every PathExpression through buildLegacyPath during
convertLocations, so that setting `.original` would flow through to
`head`/`tail` automatically. The auto-import-builtins plugin was then
simplified back to `node.path.original = rewritten`.
That combination passed the browser test suite locally but regressed
two smoke-test scenarios:
{{fn}} as keyword (but it is shadowed): it works
{{on}} as keyword (but it is shadowed): it works
These `.gjs` tests verify that a lexical JS binding (e.g. `const fn =
...`) shadows the built-in keyword inside the template. The regression
isn't due to the simpler auto-import-builtins — the plugin correctly
skips rewriting when `hasLocal('fn')` is true — but rather something
about the buildLegacyPath-upgraded PathExpression interacts poorly with
the lexical-scope path inside the v2 normalizer for this specific case.
Without the upgrade, the previous commit's auto-import-builtins
simplification also has to be reverted: without head/tail-rewriting in
the plugin, the runtime compilation path (env.meta.emberRuntime) leaves
`node.path.head` pointing at the original keyword name while
`node.path.original` contains the rewritten `__ember_keywords__.<name>`,
and the v2 normalizer reads head.name. So:
- Revert convertLocations: drop the buildLegacyPath upgrade and the
import. PathExpression stays as plain grammar-emitted data.
- Restore the manual head/tail rewrite in auto-import-builtins, with a
comment explaining why it's needed (the grammar emits PathExpression
as a plain object whose `original`, `head`, and `tail` are
independent data properties, so they must be kept in sync by hand).
Verified locally: browser test suite (9138/9138 pass) and all 3
classic-basics smoke-test scenarios (pass 3, fail 0).
The reviewer's architectural point — that setting `.original` should
propagate to `head`/`tail` — is still valid, but realizing it requires
having the Peggy grammar emit PathExpression nodes through
buildLegacyPath directly (not as a post-process step). That's a larger
change that can happen in a follow-up.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>1 parent b4b6665 commit 571a94d
2 files changed
Lines changed: 18 additions & 16 deletions
File tree
- packages
- @ember/template-compiler/lib/plugins
- @glimmer/syntax/lib/parser
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
55 | 72 | | |
56 | 73 | | |
57 | 74 | | |
| |||
Lines changed: 0 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
473 | 472 | | |
474 | 473 | | |
475 | 474 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 475 | | |
483 | 476 | | |
484 | 477 | | |
| |||
492 | 485 | | |
493 | 486 | | |
494 | 487 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | 488 | | |
500 | 489 | | |
501 | 490 | | |
| |||
506 | 495 | | |
507 | 496 | | |
508 | 497 | | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | 498 | | |
514 | 499 | | |
515 | 500 | | |
| |||
0 commit comments