Allow lone & in Unicode sets regexp classes#4218
Open
Ijtihed wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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/vcharacter 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 &. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: