Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/builtins/StringPrototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function matchAll(arg)

if (@isObject(arg)) {
if (@isRegExp(arg) && !@stringIncludesInternal.@call(@toString(arg.flags), "g"))
@throwTypeError("String.prototype.matchAll argument must not be a non-global regular expression");
@throwTypeError("String.prototype.matchAll argument must contain the global (g) flag");

var matcher = arg.@@matchAll;
if (!@isUndefinedOrNull(matcher))
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/dfg/DFGOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,7 @@ JSC_DEFINE_JIT_OPERATION(operationStringProtoFuncReplaceAllRegExpEmptyStr, JSCel
RegExp* regExp = searchValue->regExp();

if (!regExp->global()) [[unlikely]] {
throwTypeError(globalObject, scope, "String.prototype.replaceAll argument must not be a non-global regular expression"_s);
throwTypeError(globalObject, scope, "String.prototype.replaceAll argument must contain the global (g) flag"_s);
OPERATION_RETURN(scope, nullptr);
}

Expand Down Expand Up @@ -3678,7 +3678,7 @@ JSC_DEFINE_JIT_OPERATION(operationStringProtoFuncReplaceAllRegExpString, JSCell*
auto scope = DECLARE_THROW_SCOPE(vm);

if (!searchValue->regExp()->global()) [[unlikely]] {
throwTypeError(globalObject, scope, "String.prototype.replaceAll argument must not be a non-global regular expression"_s);
throwTypeError(globalObject, scope, "String.prototype.replaceAll argument must contain the global (g) flag"_s);
OPERATION_RETURN(scope, nullptr);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/StringPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ JSC_DEFINE_HOST_FUNCTION(stringProtoFuncReplaceAll, (JSGlobalObject* globalObjec
RegExpObject* regExpObject = dynamicDowncast<RegExpObject>(searchValue);
if (regExpObject && regExpObject->isSymbolReplaceFastAndNonObservable()) [[likely]] {
if (!regExpObject->regExp()->global()) [[unlikely]]
return throwVMTypeError(globalObject, scope, "String.prototype.replaceAll argument must not be a non-global regular expression"_s);
return throwVMTypeError(globalObject, scope, "String.prototype.replaceAll argument must contain the global (g) flag"_s);
JSString* string = thisValue.toString(globalObject);
RETURN_IF_EXCEPTION(scope, { });
RELEASE_AND_RETURN(scope, JSValue::encode(replaceUsingRegExpSearch(vm, globalObject, string, regExpObject, callFrame->argument(1))));
Expand All @@ -422,7 +422,7 @@ JSC_DEFINE_HOST_FUNCTION(stringProtoFuncReplaceAll, (JSGlobalObject* globalObjec
String flags = flagsValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, { });
if (!flags.contains('g')) [[unlikely]]
return throwVMTypeError(globalObject, scope, "String.prototype.replaceAll argument must not be a non-global regular expression"_s);
return throwVMTypeError(globalObject, scope, "String.prototype.replaceAll argument must contain the global (g) flag"_s);
}

JSObject* searchObject = asObject(searchValue);
Expand Down