Skip to content

Commit 4e4d4f0

Browse files
author
Gorkem Yakin
committed
[MERGE chakra-core#32] Use correct error message for String functions prohibiting a RegExp argument
Merge pull request chakra-core#32 from goyakin:string-isRegExp-error-message
2 parents 1608f35 + 11161a7 commit 4e4d4f0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

lib/Parser/rterrors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,5 @@ RT_ERROR_MSG(JSERR_ClassSuperInBaseClass, 5629, "", "Unexpected call to 'super'
322322
RT_ERROR_MSG(JSERR_ClassDerivedConstructorInvalidReturnType, 5630, "", "Derived class constructor can return only object or undefined", kjstTypeError, 0)
323323
RT_ERROR_MSG(JSERR_ClassStaticMethodCannotBePrototype, 5631, "", "Class static member cannot be named 'prototype'", kjstTypeError, 0)
324324
RT_ERROR_MSG(JSERR_ClassConstructorCannotBeCalledWithoutNew, 5632, "%s: cannot be called without the new keyword", "Class constructor cannot be called without the new keyword", kjstTypeError, 0)
325+
326+
RT_ERROR_MSG(JSERR_FunctionArgument_FirstCannotBeRegExp, 5633, "%s: first argument cannot be a RegExp", "First argument cannot be a RegExp", kjstTypeError, 0)

lib/Runtime/Library/JavascriptString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ namespace Js
12661266
{
12671267
if (!isRegExpAnAllowedArg && JavascriptRegExp::Is(args[1]))
12681268
{
1269-
JavascriptError::ThrowTypeError(scriptContext, JSERR_This_NeedString, apiNameForErrorMsg);
1269+
JavascriptError::ThrowTypeError(scriptContext, JSERR_FunctionArgument_FirstCannotBeRegExp, apiNameForErrorMsg);
12701270
}
12711271
else if (JavascriptString::Is(args[1]))
12721272
{

0 commit comments

Comments
 (0)