From 8fef573cf9c4dbf2f0fd34146756ef720e186fde Mon Sep 17 00:00:00 2001 From: user77 <329145+hexbinoct@users.noreply.github.com> Date: Tue, 4 Aug 2026 16:15:11 +0500 Subject: [PATCH] Add tests for out-of-order braced quantifier in regexp literals --- .../regexp/invalid-quantifier-out-of-order.js | 25 +++++++++++++++++++ .../u-invalid-quantifier-out-of-order.js | 22 ++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/language/literals/regexp/invalid-quantifier-out-of-order.js create mode 100644 test/language/literals/regexp/u-invalid-quantifier-out-of-order.js diff --git a/test/language/literals/regexp/invalid-quantifier-out-of-order.js b/test/language/literals/regexp/invalid-quantifier-out-of-order.js new file mode 100644 index 00000000000..e5dcd114ecf --- /dev/null +++ b/test/language/literals/regexp/invalid-quantifier-out-of-order.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 hexbinoct. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns-static-semantics-early-errors +description: > + Braced quantifier with a lower bound greater than its upper bound +info: | + QuantifierPrefix :: { DecimalDigits , DecimalDigits } + + It is a Syntax Error if the MV of the first DecimalDigits is strictly + greater than the MV of the second DecimalDigits. + + Annex B replaces Term with an alternative that admits ExtendedAtom, but + B.1.2.1 does not modify this rule, and the ExtendedAtom Quantifier + alternative is considered before the bare ExtendedAtom alternative. The + SyntaxError is therefore consistent between Annex-B and non-Annex-B + environments. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a{2,1}/; diff --git a/test/language/literals/regexp/u-invalid-quantifier-out-of-order.js b/test/language/literals/regexp/u-invalid-quantifier-out-of-order.js new file mode 100644 index 00000000000..126b22ca3c8 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-quantifier-out-of-order.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 hexbinoct. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns-static-semantics-early-errors +description: > + Braced quantifier with a lower bound greater than its upper bound (`u` flag) +info: | + QuantifierPrefix :: { DecimalDigits , DecimalDigits } + + It is a Syntax Error if the MV of the first DecimalDigits is strictly + greater than the MV of the second DecimalDigits. + + The Annex B pattern grammar does not change the syntax of patterns parsed + with the [UnicodeMode] parameter, so this rule applies unmodified. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a{2,1}/u;