Explorar el Código

Changed error from SyntaxError to RangeError; specified limit in msg

Richard Cobbe hace 8 años
padre
commit
13e7f548af
Se han modificado 3 ficheros con 4 adiciones y 4 borrados
  1. 1 1
      lib/Parser/RegexParser.cpp
  2. 1 1
      lib/Parser/rterrors.h
  3. 2 2
      test/Regex/Bug15992535.js

+ 1 - 1
lib/Parser/RegexParser.cpp

@@ -3019,7 +3019,7 @@ namespace UnifiedRegex
         Assert(nextGroupId > 0);
         if (nextGroupId > MAX_NUM_GROUPS)
         {
-            Js::JavascriptError::ThrowSyntaxError(this->scriptContext, JSERR_RegExpTooManyCapturingGroups);
+            Js::JavascriptError::ThrowRangeError(this->scriptContext, JSERR_RegExpTooManyCapturingGroups);
         }
         else
         {

+ 1 - 1
lib/Parser/rterrors.h

@@ -364,7 +364,7 @@ RT_ERROR_MSG(JSERR_InvalidIterableObject, 5671, "%s : Invalid iterable object",
 RT_ERROR_MSG(JSERR_InvalidIteratorObject, 5672, "%s : Invalid iterator object", "Invalid iterator object", kjstTypeError, 0)
 RT_ERROR_MSG(JSERR_NoAccessors, 5673, "Invalid property descriptor: accessors not supported on this object", "", kjstTypeError, 0)
 RT_ERROR_MSG(JSERR_RegExpInvalidEscape, 5674, "", "Invalid regular expression: invalid escape in unicode pattern", kjstSyntaxError, 0)
-RT_ERROR_MSG(JSERR_RegExpTooManyCapturingGroups, 5675, "", "Too many capturing groups in regular expression", kjstSyntaxError, 0)
+RT_ERROR_MSG(JSERR_RegExpTooManyCapturingGroups, 5675, "", "Regular expression cannot have more than 32,767 capturing groups", kjstRangeError, 0)
 
 //Host errors
 RT_ERROR_MSG(JSERR_HostMaybeMissingPromiseContinuationCallback, 5700, "", "Host may not have set any promise continuation callback. Promises may not be executed.", kjstTypeError, 0)

+ 2 - 2
test/Regex/Bug15992535.js

@@ -18,9 +18,9 @@ var tests = [
             );
             assert.throws(
                 () => { return new RegExp("(ab)".repeat(0x8000)); },
-                SyntaxError,
+                RangeError,
                 "regex parsing throws when the regex has more than 2^15 - 1 capturing groups",
-                "Too many capturing groups in regular expression"
+                "Regular expression cannot have more than 32,767 capturing groups"
             );
         }
     }