Skip to content

matchAll/replaceAll: clearer wording for non-global RegExp TypeError - #207

Open
robobun wants to merge 1 commit into
oven-sh:mainfrom
robobun:farm/155dceec/matchall-error-message
Open

matchAll/replaceAll: clearer wording for non-global RegExp TypeError#207
robobun wants to merge 1 commit into
oven-sh:mainfrom
robobun:farm/155dceec/matchall-error-message

Conversation

@robobun

@robobun robobun commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replaces the awkward double-negative must not be a non-global regular expression with must contain the global (g) flag in the TypeError thrown by String.prototype.matchAll and String.prototype.replaceAll when given a non-global RegExp.

Before

TypeError: String.prototype.matchAll argument must not be a non-global regular expression

After

TypeError: String.prototype.matchAll argument must contain the global (g) flag

Call sites updated

Rebased onto the upstream WebKit upgrade (#263). That upgrade moved matchAll out of builtins/StringPrototype.js (which no longer exists) into C++, so the change now touches seven C++ call sites instead of the original five:

  • Source/JavaScriptCore/runtime/StringPrototype.cpp - matchAll fast path + isRegExp slow path
  • Source/JavaScriptCore/runtime/StringPrototype.cpp - replaceAll fast path + isRegExp slow path
  • Source/JavaScriptCore/dfg/DFGOperations.cpp - replaceAll DFG paths (empty-replacement + two string-replacement operations)

All seven emit identical wording per method.

Fixes oven-sh/bun#30023

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

Walkthrough

Error messages for String.prototype.matchAll and String.prototype.replaceAll are updated across multiple implementation files. The messages now directly require the global (g) flag instead of using double-negative phrasing.

Changes

Cohort / File(s) Summary
matchAll error message
Source/JavaScriptCore/builtins/StringPrototype.js
Updated String.prototype.matchAll error message to state "must contain the global (g) flag" for non-global RegExp arguments.
replaceAll error messages
Source/JavaScriptCore/runtime/StringPrototype.cpp, Source/JavaScriptCore/dfg/DFGOperations.cpp
Updated String.prototype.replaceAll error messages in both C++ runtime and JIT operation handlers to require the global (g) flag instead of using double-negative phrasing.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change well, but it omits the required bug title, Bugzilla link, reviewed-by line, and commit-message style file list. Rewrite it to match the template: include bug title, Bugzilla URL, reviewed-by line, bug-fix explanation, and per-file change list.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: updating error message wording for matchAll/replaceAll RegExp validation.
Linked Issues check ✅ Passed All code changes directly address the linked issue's requirement to replace the double-negative error message with clearer phrasing about the global flag.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to updating error message text across four call sites as required; no unrelated or out-of-scope modifications are present.

Comment @coderabbitai help to get the list of available commands.

robobun pushed a commit to oven-sh/bun that referenced this pull request May 1, 2026
…essage

describe.skipIf guards the whole block on a runtime probe of matchAll's
TypeError, so CI stays green against the current prebuilt WebKit and the
tests auto-activate once WEBKIT_VERSION is bumped to a build that
includes oven-sh/WebKit#207.
robobun pushed a commit to oven-sh/bun that referenced this pull request May 1, 2026
Pairs with oven-sh/WebKit#207 — asserts the new 'must contain the
global (g) flag' wording on String.prototype.matchAll and replaceAll
(including the DFG-tier replaceAll fast paths).

Fixes #30023
robobun pushed a commit to oven-sh/bun that referenced this pull request May 1, 2026
…essage

describe.skipIf guards the whole block on a runtime probe of matchAll's
TypeError, so CI stays green against the current prebuilt WebKit and the
tests auto-activate once WEBKIT_VERSION is bumped to a build that
includes oven-sh/WebKit#207.
Jarred-Sumner pushed a commit to oven-sh/bun that referenced this pull request May 4, 2026
Pairs with oven-sh/WebKit#207 — asserts the new 'must contain the
global (g) flag' wording on String.prototype.matchAll and replaceAll
(including the DFG-tier replaceAll fast paths).

Fixes #30023
Jarred-Sumner pushed a commit to oven-sh/bun that referenced this pull request May 4, 2026
…essage

describe.skipIf guards the whole block on a runtime probe of matchAll's
TypeError, so CI stays green against the current prebuilt WebKit and the
tests auto-activate once WEBKIT_VERSION is bumped to a build that
includes oven-sh/WebKit#207.
Replaces

  String.prototype.matchAll argument must not be a non-global regular expression

with

  String.prototype.matchAll argument must contain the global (g) flag

The old wording's "must not be a non-global" double-negative is awkward.
The new wording directly names the fix.

Updates all seven call sites (matchAll + replaceAll, including the DFG
paths) in runtime/StringPrototype.cpp and dfg/DFGOperations.cpp.

Fixes oven-sh/bun#30023
@robobun
robobun force-pushed the farm/155dceec/matchall-error-message branch from ff2d5b1 to cec9fe4 Compare July 2, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message for RegExp.prototype.matchAll

1 participant