Skip to content

Fix escaped keyword ASI after class field initializers (#64883) - #65014

Open
Timur Vural (timurzvural) wants to merge 1 commit into
microsoft:mainfrom
timurzvural:fix/64883-escaped-keyword-asi
Open

Timur Vural (timurzvural) wants to merge 1 commit into
microsoft:mainfrom
timurzvural:fix/64883-escaped-keyword-asi

Conversation

@timurzvural

Copy link
Copy Markdown

Summary

Fixes #64883 — Escaped in / instanceof after class field initializers.

After a class field initializer, Unicode-escaped \u{69}n / \u{69}nstanceof on the next line were parsed as the in / instanceof operators (TS1260 + parse error). Per ECMA-262, keyword terminals cannot be expressed with Unicode escapes, so these should be IdentifierNames (matching V8).

Change: Treat escaped keywords as non-operators in the binary-operator path (parseBinaryExpressionRest / isBinaryOperator) so ASI can end the previous expression and the escaped name can start a new class member. Unescaped in after a field initializer still continues the expression (test262 fields-asi-5.js).

Test plan

  • Added Go unit tests: TestParseEscapedInInstanceofAfterClassField, TestParseUnescapedInContinuesClassFieldInitializer
  • CI / existing test suite

Relates to

This focused PR replaces the parser portion of the combined #65013 (which is being closed in favor of two single-issue PRs).

AI assistance disclosure

This change was authored with Cursor Agent (an LLM-based coding agent). A human operator directed the investigation at this specific open issue, reviewed the resulting patch, and is submitting it for review. Per CONTRIBUTING.md, AI tool use is disclosed here.

Do not treat Unicode-escaped keywords as binary operators so
`\u{69}n` / `\u{69}nstanceof` after a class field initializer become
IdentifierNames (matching ECMA-262 and V8). Unescaped `in` still
continues the initializer.

AI assistance disclosure: this change was authored with Cursor Agent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the parser change allowing escaped keywords to begin new class members after field initializers.

No open issues 🎉

What changed in this PR

Fixes #64883 in the native TypeScript parser by allowing escaped keyword names after class field initializers to start new members through automatic semicolon insertion.

Changes:

  • Excludes Unicode-escaped keywords from binary-operator parsing and detection.
  • Adds parser tests for escaped in / instanceof fields and preserves unescaped in as an operator.
File Description
tsc/​internal/​parser/​parser.go Adds an escaped-keyword check to both binary-operator paths.
tsc/​internal/​parser/​parser_test.go Tests escaped class field names and unescaped operator behavior.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Escaped in / instanceof after a class field initializer is parsed as a binary operator instead of a new member

2 participants