Skip to content

Allow lone & in Unicode sets regexp classes#4218

Open
Ijtihed wants to merge 1 commit into
microsoft:mainfrom
Ijtihed:fix-regexp-unicode-sets-lone-ampersand
Open

Allow lone & in Unicode sets regexp classes#4218
Ijtihed wants to merge 1 commit into
microsoft:mainfrom
Ijtihed:fix-regexp-unicode-sets-lone-ampersand

Conversation

@Ijtihed
Copy link
Copy Markdown

@Ijtihed Ijtihed commented Jun 6, 2026

Fixes microsoft/TypeScript#62707

port of microsoft/TypeScript#63535.

This updates the native scanner to allow a lone & in Unicode Sets regexp character classes while also preserving && handling for class set intersection.

AI assistance disclosure: I used Codex to help port and test this change. Of course went over everything myself afterwards.

Validation:

  • go test ./internal/testrunner -run 'TestLocal/regularExpressionUnicodeSetsLoneAmpersand'
  • go test ./internal/testrunner -run 'TestSubmodule/regularExpressionScanning'
  • npx hereby format
  • npx hereby check:format
  • npx hereby lint
  • npx hereby build
  • npx hereby test failed only in internal/fswatch because local Windows symlink privileges are unavailable
  • go test all packages except internal/fswatch passed locally

Copilot AI review requested due to automatic review settings June 6, 2026 10:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a compiler regression test ensuring lone & characters are accepted inside Unicode Sets character classes (/v), and updates the regexp scanner to treat & as an operator only when it appears as &&.

Changes:

  • Added a new compiler test case covering lone & in /v character classes.
  • Added baseline outputs (types/symbols/js) for the new test.
  • Updated the regexp scanner’s handling of & to only special-case &&.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testdata/tests/cases/compiler/regularExpressionUnicodeSetsLoneAmpersand.ts New regression test for lone & in /v character classes.
testdata/baselines/reference/compiler/regularExpressionUnicodeSetsLoneAmpersand.types Baseline type output for the new test.
testdata/baselines/reference/compiler/regularExpressionUnicodeSetsLoneAmpersand.symbols Baseline symbol output for the new test.
testdata/baselines/reference/compiler/regularExpressionUnicodeSetsLoneAmpersand.js Baseline JS emit output for the new test.
internal/scanner/regexp.go Scanner change to only treat && as special and allow lone &.

Comment thread internal/scanner/regexp.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS1508: Unexpected '?'. Did you mean to escape it with backslash? shouldn't report even with v flag

2 participants