Skip to content

Allow lone & in Unicode sets regexp classes - #4218

Merged
Wesley Wigham (weswigham) merged 1 commit into
microsoft:mainfrom
Ijtihed:fix-regexp-unicode-sets-lone-ampersand
Aug 13, 2026
Merged

Allow lone & in Unicode sets regexp classes#4218
Wesley Wigham (weswigham) merged 1 commit into
microsoft:mainfrom
Ijtihed:fix-regexp-unicode-sets-lone-ampersand

Conversation

@Ijtihed

Copy link
Copy Markdown
Contributor

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

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.

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
@Ijtihed

Ijtihed Kilani (Ijtihed) commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Ryan Cavanaugh (@RyanCavanaugh) I love the label lmfao

edit: nvm. i'd love an explanation though..

@RyanCavanaugh

Copy link
Copy Markdown
Member

Ijtihed Kilani (@Ijtihed) label gets applied when someone seems to have a suspiciously high count of PRs and has possibly run afoul of our "no bulk contributors" policy. What made you decide to fix that issue in particular?

@Ijtihed

Copy link
Copy Markdown
Contributor Author

Ijtihed Kilani (@Ijtihed) label gets applied when someone seems to have a suspiciously high count of PRs and has possibly run afoul of our "no bulk contributors" policy. What made you decide to fix that issue in particular?

tbch I'm a somewhat junior swe and was browsing issues and saw that one and thought it would be cool to learn on. I didn't run into the issue myself or anything beforehand

@RyanCavanaugh

Copy link
Copy Markdown
Member

graphemecluster (@graphemecluster) in case you want to see it

@graphemecluster

graphemecluster (graphemecluster) commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh) Looks fine by itself for this small fix, though I actually planned to port microsoft/TypeScript#62716 but I haven't done so. I would prefer porting that PR if its scope is not wider than your expectation.

@Ijtihed

Copy link
Copy Markdown
Contributor Author

so what's the consensus here? :) I can close if needed

@Ijtihed

Copy link
Copy Markdown
Contributor Author

anything left for me to do here? thanks!
/

@weswigham
Wesley Wigham (weswigham) added this pull request to the merge queue Aug 13, 2026
Merged via the queue into microsoft:main with commit 3d981a4 Aug 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

5 participants