Add tests for out-of-order braced quantifier in regexp literals - #5103
Conversation
ptomato
left a comment
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."
621cd8b to
387254f
Compare
|
This has been approved since August 14 and still merges cleanly, so I wanted to check I have not rebased it, on purpose. Its checks are the pre-migration CircleCI engine runs |
387254f to
8fef573
Compare
|
The engine262 failure indicates a defect in test262harness, not engine262, the uploaded artifact shows it's throwing the SyntaxError but test262harness is registering a test failure. |
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.