Add tests for out-of-order braced quantifier in regexp literals - #5103
Open
hexbinoct wants to merge 1 commit into
Open
Add tests for out-of-order braced quantifier in regexp literals#5103hexbinoct wants to merge 1 commit into
hexbinoct wants to merge 1 commit into
Conversation
ptomato
approved these changes
Aug 14, 2026
ptomato
left a comment
Contributor
There was a problem hiding this comment.
Makes sense, thanks.
If I'm reading the spec correctly, it is indeed the case that this is a SyntaxError because of the early error for PrimaryExpression: "It is a Syntax Error if IsValidRegularExpressionLiteral(RegularExpressionLiteral) is false."
hexbinoct
force-pushed
the
quantifier-out-of-order-tests
branch
from
August 15, 2026 00:42
621cd8b to
387254f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #819.
test262 currently covers the
{n,m}case where n > m only through the RegExpconstructor, in
test/built-ins/RegExp/15.10.2.5-3-1.js(new RegExp("0{2,1}")), which is a runtime error. The regexp literal form is theearly error, and it has no coverage. There is also an incidental use in
test/annexB/built-ins/RegExp/prototype/compile/pattern-string-invalid.js, butthat test is about
compile.This adds two tests in
test/language/literals/regexp/:invalid-quantifier-out-of-order.jsfor/a{2,1}/u-invalid-quantifier-out-of-order.jsfor/a{2,1}/uOne note on the issue text. When this was filed in 2017 the rule lived in step 3
of the runtime semantics for
Term :: Atom Quantifier, and the observation therewas that it looked like a runtime error rather than an early error, with V8 the
only engine treating it that way. In the current spec it is an early error, in
22.2.1.1:
so
phase: parseis right for both files.Annex B does not change this. B.1.2.1 adds the
ExtendedAtom :: InvalidBracedQuantifiererror and modifies the NonemptyClassRanges rules, butleaves the QuantifierPrefix rule alone, and the Annex B
Termordering considersExtendedAtom Quantifierbefore bareExtendedAtom, soa{2,1}still binds asan atom with a quantifier. The SyntaxError is the same in Annex-B and
non-Annex-B environments.
Verified with the repo linter, and run against V8 and engine262. I also checked
that swapping
{2,1}for{1,2}makes both tests fail, so they are not passingbecause of an unrelated parse error.
The Test262 CLA is signed. I have used my GitHub handle on the copyright lines;
happy to change them to my legal name from the CLA if you would prefer that.