Skip to content

Conversation

@ljharb
Copy link
Contributor

@ljharb ljharb commented Dec 9, 2025

Fixes #55843

(it would be very ideal to get this bugfix into v5, assuming v6 is the go implementation)

Copilot AI review requested due to automatic review settings December 9, 2025 21:32
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Dec 9, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 9, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

1 similar comment
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copy link

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.

Copilot wasn't able to review any files in this pull request.

@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #55843. If you can get it accepted, this PR will have a better chance of being reviewed.

@ljharb ljharb force-pushed the patch-2 branch 2 times, most recently from fa72d1b to 7decdc8 Compare December 9, 2025 22:11
@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Dec 10, 2025
@DanielRosenwasser
Copy link
Member

v6 will be in TS, v7 will be the Go-based implementation.

@ljharb
Copy link
Contributor Author

ljharb commented Dec 10, 2025

phew, thanks :-)

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

Will this show up in the nightly v6 build the same day it's merged?

@jakebailey
Copy link
Member

Yes.

For safety...

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 11, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62873/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,387 50,387 ~ ~ ~ p=1.000 n=6
Memory used 195,549k (± 0.76%) 193,712k (± 0.97%) ~ 192,474k 196,157k p=0.128 n=6
Parse Time 1.30s (± 1.02%) 1.30s (± 0.63%) ~ 1.29s 1.31s p=0.402 n=6
Bind Time 0.76s 0.76s ~ ~ ~ p=1.000 n=6
Check Time 9.84s (± 0.37%) 9.88s (± 0.31%) ~ 9.85s 9.92s p=0.106 n=6
Emit Time 2.75s (± 0.55%) 2.74s (± 0.90%) ~ 2.71s 2.78s p=0.627 n=6
Total Time 14.65s (± 0.38%) 14.68s (± 0.20%) ~ 14.64s 14.72s p=0.418 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 955,823 955,845 +22 (+ 0.00%) ~ ~ p=0.001 n=6
Types 415,853 415,860 +7 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 1,253,902k (± 0.01%) 1,253,878k (± 0.00%) ~ 1,253,845k 1,253,926k p=1.000 n=6
Parse Time 6.55s (± 0.58%) 6.52s (± 0.69%) ~ 6.46s 6.57s p=0.170 n=6
Bind Time 1.96s (± 0.21%) 1.96s (± 0.38%) ~ 1.95s 1.97s p=1.000 n=6
Check Time 32.41s (± 0.21%) 32.32s (± 0.29%) ~ 32.21s 32.48s p=0.077 n=6
Emit Time 14.99s (± 0.56%) 15.01s (± 0.41%) ~ 14.94s 15.11s p=0.422 n=6
Total Time 55.91s (± 0.21%) 55.81s (± 0.22%) ~ 55.64s 55.95s p=0.173 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,723,733 2,723,802 +69 (+ 0.00%) ~ ~ p=0.001 n=6
Types 937,508 937,517 +9 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,051,590k (± 0.01%) 3,051,643k (± 0.00%) ~ 3,051,512k 3,051,788k p=0.378 n=6
Parse Time 10.38s (± 1.29%) 10.44s (± 0.71%) ~ 10.35s 10.51s p=0.629 n=6
Bind Time 2.79s (± 0.64%) 2.78s (± 0.62%) ~ 2.76s 2.80s p=0.288 n=6
Check Time 112.63s (± 1.52%) 111.50s (± 0.82%) ~ 110.67s 113.18s p=0.128 n=6
Emit Time 0.38s (± 3.33%) 0.38s (± 1.99%) ~ 0.37s 0.39s p=0.788 n=6
Total Time 126.18s (± 1.37%) 125.10s (± 0.78%) ~ 124.20s 126.87s p=0.128 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,077 1,252,077 ~ ~ ~ p=1.000 n=6
Types 259,856 259,856 ~ ~ ~ p=1.000 n=6
Memory used 2,387,668k (± 0.04%) 2,448,117k (± 6.08%) ~ 2,386,688k 2,752,028k p=0.689 n=6
Parse Time 5.16s (± 0.45%) 5.17s (± 1.09%) ~ 5.09s 5.24s p=0.810 n=6
Bind Time 1.86s (± 0.79%) 1.86s (± 0.63%) ~ 1.85s 1.88s p=0.680 n=6
Check Time 35.52s (± 0.60%) 35.48s (± 0.92%) ~ 34.95s 35.93s p=0.810 n=6
Emit Time 3.05s (± 4.73%) 3.00s (± 1.68%) ~ 2.96s 3.10s p=0.688 n=6
Total Time 45.59s (± 0.64%) 45.53s (± 0.68%) ~ 45.10s 46.02s p=1.000 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,077 1,252,077 ~ ~ ~ p=1.000 n=6
Types 259,856 259,856 ~ ~ ~ p=1.000 n=6
Memory used 3,061,581k (± 9.67%) 3,183,091k (± 0.02%) ~ 3,181,841k 3,183,718k p=0.093 n=6
Parse Time 6.78s (± 0.94%) 6.82s (± 0.75%) ~ 6.72s 6.86s p=0.378 n=6
Bind Time 2.26s (± 1.52%) 2.27s (± 0.76%) ~ 2.24s 2.29s p=0.630 n=6
Check Time 43.00s (± 0.35%) 43.28s (± 0.18%) +0.28s (+ 0.66%) 43.19s 43.39s p=0.005 n=6
Emit Time 3.52s (± 1.58%) 3.50s (± 2.29%) ~ 3.39s 3.59s p=0.748 n=6
Total Time 55.58s (± 0.36%) 55.88s (± 0.29%) +0.30s (+ 0.54%) 55.68s 56.11s p=0.037 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 264,690 264,690 ~ ~ ~ p=1.000 n=6
Types 104,069 104,069 ~ ~ ~ p=1.000 n=6
Memory used 442,809k (± 0.02%) 442,809k (± 0.02%) ~ 442,694k 442,946k p=1.000 n=6
Parse Time 2.84s (± 0.62%) 2.85s (± 0.70%) ~ 2.83s 2.88s p=0.325 n=6
Bind Time 1.16s 1.16s (± 0.45%) ~ 1.15s 1.16s p=0.174 n=6
Check Time 16.05s (± 0.43%) 16.02s (± 0.32%) ~ 15.93s 16.08s p=0.574 n=6
Emit Time 1.31s (± 1.36%) 1.31s (± 1.74%) ~ 1.29s 1.34s p=0.870 n=6
Total Time 21.36s (± 0.35%) 21.34s (± 0.22%) ~ 21.25s 21.37s p=0.685 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,493 225,497 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 94,373 94,374 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 369,858k (± 0.03%) 369,793k (± 0.02%) ~ 369,731k 369,877k p=0.471 n=6
Parse Time 2.85s (± 1.25%) 2.85s (± 1.32%) ~ 2.81s 2.90s p=0.872 n=6
Bind Time 1.66s (± 1.42%) 1.65s (± 1.29%) ~ 1.63s 1.69s p=0.627 n=6
Check Time 16.59s (± 0.27%) 16.62s (± 0.49%) ~ 16.53s 16.75s p=0.686 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 21.11s (± 0.28%) 21.13s (± 0.53%) ~ 21.02s 21.27s p=0.872 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,069,745 4,069,762 +17 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,283,244 1,283,250 +6 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,859,060k (± 0.00%) 3,859,106k (± 0.00%) ~ 3,859,009k 3,859,199k p=0.575 n=6
Parse Time 15.70s (± 0.61%) 15.63s (± 0.54%) ~ 15.51s 15.71s p=0.148 n=6
Bind Time 5.40s (± 2.45%) 5.40s (± 2.13%) ~ 5.29s 5.55s p=1.000 n=6
Check Time 113.16s (± 2.92%) 112.58s (± 1.83%) ~ 110.03s 114.47s p=0.936 n=6
Emit Time 40.15s (± 5.63%) 39.87s (± 4.88%) ~ 38.65s 43.79s p=0.873 n=6
Total Time 174.41s (± 3.11%) 173.47s (± 1.41%) ~ 169.71s 176.31s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 40 40 ~ ~ ~ p=1.000 n=6
Symbols 380,693 380,693 ~ ~ ~ p=1.000 n=6
Types 166,792 166,792 ~ ~ ~ p=1.000 n=6
Memory used 539,527k (± 0.02%) 539,517k (± 0.02%) ~ 539,416k 539,631k p=1.000 n=6
Parse Time 4.71s (± 0.62%) 4.70s (± 0.46%) ~ 4.68s 4.74s p=0.366 n=6
Bind Time 2.03s (± 1.34%) 2.04s (± 1.45%) ~ 1.99s 2.08s p=0.373 n=6
Check Time 22.89s (± 0.39%) 22.96s (± 0.32%) ~ 22.83s 23.03s p=0.092 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.63s (± 0.33%) 29.71s (± 0.18%) ~ 29.60s 29.75s p=0.054 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 693,864 693,877 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Types 211,665 211,672 +7 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 589,158k (± 0.03%) 589,166k (± 0.02%) ~ 589,066k 589,347k p=0.378 n=6
Parse Time 4.17s (± 0.75%) 4.16s (± 0.65%) ~ 4.13s 4.20s p=0.560 n=6
Bind Time 1.39s (± 1.48%) 1.41s (± 0.39%) ~ 1.40s 1.41s p=0.360 n=6
Check Time 21.28s (± 1.94%) 21.34s (± 1.48%) ~ 20.76s 21.55s p=0.689 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 26.84s (± 1.59%) 26.91s (± 1.21%) ~ 26.32s 27.13s p=0.688 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62873/merge:

Everything looks good!

@jakebailey jakebailey added this pull request to the merge queue Dec 11, 2025
Merged via the queue into microsoft:main with commit bbb5322 Dec 11, 2025
33 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Dec 11, 2025
@bbrk24
Copy link

bbrk24 commented Dec 11, 2025

I'm not sure this actually resolves the linked issue -- the linked issue talks about passing custom objects that implement the [Symbol.matchAll] method, not just RegExp instances and strings.

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

ah, that's true - it's more like the proper resolution to the incorrectly-closed #47310.

@jakebailey
Copy link
Member

That's critical context. If I had known this was actually for that issue, I would not have approved and merged this PR.

It's well known that our lib types can be slightly more strict than "the spec technically allows this type because of implicit conversions". I could argue then that this function should accept number because that could be stringified, or something.

jakebailey added a commit that referenced this pull request Dec 11, 2025
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Dec 11, 2025

#47310 was correctly closed and this shouldn't have been merged.

This PR allows

const someStr = "(";
"foo".matchAll(someStr)

which throws a runtime error! It's super important that people understand that the argument is being regexified here

@bbrk24
Copy link

bbrk24 commented Dec 11, 2025

Thankfully this is easy to test, and it does error:

Screenshot 2025-12-11 at 4 12 04 PM

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

Then that's a major implementation bug - the spec does not say to do that. https://tc39.es/ecma262/#sec-string.prototype.matchall

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

I will file implementation bugs for every affected engine, but matchAll absolutely should not coerce to a regexp.

@RyanCavanaugh
Copy link
Member

@ljharb What is step 5 doing if not creating a regexp?

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

shit, you're right. clearly my memory is incorrect, and i'm astonished it went in this way. Please do revert this PR, then, and I apologize for the confusion.

@Renegade334
Copy link
Contributor

FWIW, this would only have brought matchAll in line with the signature already used by match in lib.es5, which includes the coercion behaviour. If one isn't kosher, then should the other... well, match?

@jakebailey
Copy link
Member

Yeah, if we have a string somewhere else, that is probably a mistake

@ljharb
Copy link
Contributor Author

ljharb commented Dec 11, 2025

The more I've thought about it, the more I've realized that that was indeed the reason this horrific design choice was made - to be consistent with match.

So yes, I think either both should allow a string, or neither should, and I'm perfectly content for it to be "neither". (same with all the other regex-taking string methods)

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

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

String#matchAll is too restrictive in its parameter type

7 participants