Allow lone & in Unicode sets regexp classes - #4218
Conversation
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 &. |
|
Ryan Cavanaugh (@RyanCavanaugh) I love the label lmfao edit: nvm. i'd love an explanation though.. |
|
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 |
|
graphemecluster (@graphemecluster) in case you want to see it |
|
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. |
|
so what's the consensus here? :) I can close if needed |
|
anything left for me to do here? thanks! |
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: