Skip to content

[breaking] Expose the script parser's diagnostics as ast.errors instead of throwing - #81

Merged
NullVoxPopuli merged 1 commit into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:expose-parse-errors
Aug 25, 2026
Merged

NullVoxPopuli merged 1 commit into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:expose-parse-errors

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

oxc-parser has no fault-tolerant mode: on an unrecoverable script error it returns an empty program.body, which toTree currently hands back looking exactly like an empty file.

This forwards oxc's diagnostics on the File node:

let ast = toTree(`let planets = []);`);
ast.program.body.length; // 0
ast.errors.length;       // 1

Type added (FileNode.errors: ParseError[]), README note, tests. The custom-parser path is unchanged (it returns whatever the parser returned).

Context: glint's standalone transform (typed-ember/glint#1226) degrades to no-imports / context-this when the script doesn't parse; with this it can at least tell that it did.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN

oxc-parser returns an empty program.body on an unrecoverable script
error, indistinguishable from an empty file. Forward its diagnostics on
the File node so callers can tell the two apart.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN
NullVoxPopuli-ai-agent added a commit to NullVoxPopuli-ai-agent/glint that referenced this pull request Aug 25, 2026
Mid-keystroke, a broken script already goes one of two ways on the TS
path: content-tag fails and the raw source is kept with verification
off so the type-checker's recovering parser powers completions, or swc
tolerates it and the templates are emitted normally. oxc tolerates less
than swc, so the standalone entry had a third mode in between: templates
emitted with no import bindings or placement. Collapse it into the
first: when ember-estree reports script errors (ast.errors,
NullVoxPopuli/ember-estree#81), record one as a content-tag-style error
and keep the raw source, exactly as on content-tag failure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FsXgxh6vNRWMCNcAQ3g6TN
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label Aug 25, 2026
@NullVoxPopuli NullVoxPopuli changed the title Expose the script parser's diagnostics as ast.errors [breaking] Expose the script parser's diagnostics as ast.errors instead of throwing Aug 25, 2026
@NullVoxPopuli
NullVoxPopuli merged commit 3e6e91f into NullVoxPopuli:main Aug 25, 2026
6 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the expose-parse-errors branch August 25, 2026 17:54
@github-actions github-actions Bot mentioned this pull request Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants