Skip to content

Sort content-tag results into source order before building placeholders - #77

Merged
NullVoxPopuli merged 1 commit into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:sort-template-ranges
Aug 24, 2026
Merged

NullVoxPopuli merged 1 commit into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:sort-template-ranges

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

content-tag reports a class's own template before a template that sits earlier in its heritage clause:

class A extends mixin(Object, <template>heritage</template>) {
  <template>own</template>
}

parse() returns [class-member @ 60, expression @ 30]. toPlaceholderJS walks the source forward with a cursor, so the second result slices an empty string and the placeholder JS is misaligned; oxc then fails on the whole file and program.body comes back empty.

Sorting the results by start offset fixes it. Test added.

Found while wiring glint's rewriteModuleStandalone (typed-ember/glint#1226) onto ember-estree; glint's own preprocess had the same bug.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN

content-tag reports a class's own template before a template that sits
earlier in its heritage clause, so `toPlaceholderJS`'s forward walk
produced misaligned placeholder JS and the whole file failed to parse.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Aug 24, 2026
@NullVoxPopuli
NullVoxPopuli merged commit aa1d17b into NullVoxPopuli:main Aug 24, 2026
5 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the sort-template-ranges branch August 24, 2026 23:21
@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
NullVoxPopuli-ai-agent added a commit to NullVoxPopuli-ai-agent/glint that referenced this pull request Aug 24, 2026
ember-estree (content-tag + oxc-parser) gives a real ESTree for the
file. Walking its outer tree, with an ancestor stack, before templates
are spliced in reproduces `templateThisBinding` and
`collectImportedBindings` directly, so the hand-written tokenizer goes.

Known divergence: oxc yields an empty program on an unrecoverable
script syntax error, where TypeScript's parser keeps going. Such a file
is emitted without import bindings or placement (bare identifiers still
resolve lexically); the checker reports the syntax error either way.

Two parity cases depend on ember-estree fixes (NullVoxPopuli/ember-estree#77
and typed-ember#78) and are marked `test.fails` until those ship.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN
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