Bug 289337
| Summary: | REGRESSION (285042@main-285687@main): `RegExp["$&"]` incorrectly returns an empty string | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | RiskyMH <webkit> |
| Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> |
| Status: | RESOLVED FIXED | ||
| Severity: | Minor | CC: | ben, mark.lam, msaboff, webkit-bug-importer, yijia_huang, ysuzuki |
| Priority: | P2 | Keywords: | InRadar, Regression |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://github.com/oven-sh/bun/issues/17978 | ||
RiskyMH
`RegExp["$&"]` should return the last matched substring but now returns an empty string when using `.match(/bar/g)`. However, it works if the match includes a capturing group.
```js
"foo bar baz".match(/bar/g);
console.log([RegExp["$&"]]); // Expected: ["bar"], Current: [""]
"foo bar baz".match(/ba(r)/g);
console.log([RegExp["$&"]]); // Expected and Current: ["bar"]
```
Observed Behavior:
- Broke between WebKit commits `96471cc` and `1b53bfc`
- See bun's fork diff https://github.com/oven-sh/WebKit/compare/543cca2...9b84f43 (bun `1.1.33..1.1.34`)
Possible Cause: https://commits.webkit.org/285090@main
---
reported on Bun's repo https://github.com/oven-sh/bun/issues/17978
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/146622507>
Yusuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/42177
EWS
Committed 291881@main (cc0a0f907148): <https://commits.webkit.org/291881@main>
Reviewed commits have been landed. Closing PR #42177 and removing active labels.
EWS
Committed 289651.257@safari-7621-branch (90e15f4a2340): <https://commits.webkit.org/289651.257@safari-7621-branch>
Reviewed commits have been landed. Closing PR #2776 and removing active labels.