Merge pull request #1923 from bakkot/less-regex-eval

Reduce uses of `eval` for regex literal syntax
This commit is contained in:
Rick Waldron 2018-11-08 09:18:48 -05:00 committed by GitHub
commit b1e15cd326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 925 additions and 101 deletions

View File

@ -1,35 +0,0 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Named groups in Unicode RegExps have some syntax errors and some
compatibility escape fallback behavior.
esid: prod-GroupSpecifier
features: [regexp-named-groups]
includes: [compareArray.js]
---*/
assert.throws(SyntaxError, () => eval("/(?<>a)/"));
assert.throws(SyntaxError, () => eval("/(?<aa)/"));
assert.throws(SyntaxError, () => eval("/(?<42a>a)/"));
assert.throws(SyntaxError, () => eval("/(?<:a>a)/"));
assert.throws(SyntaxError, () => eval("/(?<a:>a)/"));
assert.throws(SyntaxError, () => eval("/(?<a>a)(?<a>a)/"));
assert.throws(SyntaxError, () => eval("/(?<a>a)(?<b>b)(?<a>a)/"));
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k/"));
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<a/"));
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<>/"));
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<b>/"));
assert.throws(SyntaxError, () => eval("/(?<a>a)\\k<ab>/"));
assert.throws(SyntaxError, () => eval("/(?<ab>a)\\k<a>/"));
assert.throws(SyntaxError, () => eval("/\\k<a>(?<ab>a)/"));
assert.throws(SyntaxError, () => eval("/\\k<a(?<a>a)/"));
// A couple of corner cases around '\k' as named back-references vs. identity
// escapes.
assert(/\k<a>(?<a>x)/.test("x"));
assert.throws(SyntaxError, () => eval("/\\k<a>(?<b>x)/"));
assert.throws(SyntaxError, () => eval("/\\k<a(?<a>.)/"));
assert.throws(SyntaxError, () => eval("/\\k(?<a>.)/"));

View File

@ -5,40 +5,19 @@
description: Exotic named group names in non-Unicode RegExps description: Exotic named group names in non-Unicode RegExps
esid: prod-GroupSpecifier esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
includes: [compareArray.js]
---*/ ---*/
assert.sameValue("a", /(?<π>a)/.exec("bab").groups.π); assert.sameValue("a", /(?<π>a)/.exec("bab").groups.π);
assert.throws(SyntaxError, () => eval('/(?<\\u{03C0}>a)/'), "\\u{} escapes allowed only in Unicode mode");
assert.sameValue("a", /(?<π>a)/.exec("bab").groups.\u03C0); assert.sameValue("a", /(?<π>a)/.exec("bab").groups.\u03C0);
assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$); assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$);
assert.sameValue("a", /(?<_>a)/.exec("bab").groups._); assert.sameValue("a", /(?<_>a)/.exec("bab").groups._);
assert.throws(SyntaxError, () => eval('/(?<$𐒤>a)/'), "Individual surrogates not in ID_Continue");
assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\u200C); assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\u200C);
assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D); assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D);
assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups._ಠ); assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups._ಠ);
assert.throws(SyntaxError, () => eval('/(?<❤>a)/'));
assert.throws(SyntaxError, () => eval('/(?<𐒤>a)/'), "Individual surrogate not in ID_Start.");
// Unicode escapes in capture names. // Unicode escapes in capture names.
assert.throws(SyntaxError, () => eval("/(?<a\\uD801\uDCA4>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\\uD801>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\\uDCA4>.)/"));
assert(/(?<\u0041>.)/.test("a")); assert(/(?<\u0041>.)/.test("a"));
assert.throws(SyntaxError, () => eval("/(?<a\\u{104A4}>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\\u{10FFFF}>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lea");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trai");
assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate"); assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate");
// Bracketed escapes are not allowed;
// 4-char escapes must be the proper ID_Start/ID_Continue // 4-char escapes must be the proper ID_Start/ID_Continue
assert.throws(SyntaxError, () => eval("/(?<a\\uD801>.)/"), "Lead");
assert.throws(SyntaxError, () => eval("/(?<a\\uDCA4>.)/"), "Trail");
assert.throws(SyntaxError, () => eval("/(?<\\u{0041}>.)/"), "Non-surrogate");
assert.throws(SyntaxError, () => eval("/(?<a\\u{104A4}>.)/"), "Surrogate, ID_Continue");
assert(RegExp("(?<\\u0041>.)").test("a"), "Non-surrogate"); assert(RegExp("(?<\\u0041>.)").test("a"), "Non-surrogate");
// Backslash is not allowed as ID_Start and ID_Continue
assert.throws(SyntaxError, () => eval("/(?<\\>.)/"), "'\' misclassified as ID_Start");
assert.throws(SyntaxError, () => eval("/(?<a\\>.)/"), "'\' misclassified as ID_Continue");

View File

@ -1,29 +0,0 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Various syntax errors for Unicode RegExps containing named groups
esid: prod-GroupSpecifier
features: [regexp-named-groups]
---*/
assert.throws(SyntaxError, () => eval("/(?<>a)/u"), "Empty name");
assert.throws(SyntaxError, () => eval("/(?<aa)/u"), "Unterminated name");
assert.throws(SyntaxError, () => eval("/(?<42a>a)/u"), "Name starting with digits");
assert.throws(SyntaxError, () => eval("/(?<:a>a)/u"), "Name starting with invalid char");
assert.throws(SyntaxError, () => eval("/(?<a:>a)/u"), "Name containing with invalid char");
assert.throws(SyntaxError, () => eval("/(?<a>a)(?<a>a)/u"), "Duplicate name");
assert.throws(SyntaxError, () => eval("/(?<a>a)(?<b>b)(?<a>a)/u"), "Duplicate name");
assert.throws(SyntaxError, () => eval("/\\k<a>/u"), "Invalid reference");
assert.throws(SyntaxError, () => eval("/\\k<a/u"), "Unterminated reference");
assert.throws(SyntaxError, () => eval("/\\k<>/u"), "Empty reference");
assert.throws(SyntaxError, () => eval("/\\k/u"), "Lone \k");
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k/u"), "Lone \k");
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<a/u"), "Unterminated reference");
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<>/u"), "Empty reference");
assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<b>/u"), "Invalid reference");
assert.throws(SyntaxError, () => eval("/(?<a>a)\\k<ab>/u"), "Invalid reference");
assert.throws(SyntaxError, () => eval("/(?<ab>a)\\k<a>/u"), "Invalid reference");
assert.throws(SyntaxError, () => eval("/\\k<a>(?<ab>a)/u"), "Invalid reference");
assert.throws(SyntaxError, () => eval("/(?<a>\\a)/u"), "Identity escape in capture");

View File

@ -17,30 +17,14 @@ assert.sameValue("a", /(?<$𐒤>a)/u.exec("bab").groups.$𐒤);
assert.sameValue("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C); assert.sameValue("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C);
assert.sameValue("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D); assert.sameValue("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D);
assert.sameValue("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups._ಠ); assert.sameValue("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups._ಠ);
assert.throws(SyntaxError, () => eval('/(?<❤>a)/u'));
assert.throws(SyntaxError, () => eval('/(?<𐒤>a)/u'), "ID_Continue but not ID_Start.");
// Unicode escapes in capture names. // Unicode escapes in capture names.
assert(/(?<a\uD801\uDCA4>.)/u.test("a"), "\\u Lead \\u Trail"); assert(/(?<a\uD801\uDCA4>.)/u.test("a"), "\\u Lead \\u Trail");
assert.throws(SyntaxError, () => eval("/(?<a\\uD801>.)/u"), "\\u Lea");
assert.throws(SyntaxError, () => eval("/(?<a\\uDCA4>.)/u"), "\\u Trai");
assert(/(?<\u0041>.)/u.test("a"), "\\u NonSurrogate"); assert(/(?<\u0041>.)/u.test("a"), "\\u NonSurrogate");
assert(/(?<\u{0041}>.)/u.test("a"), "\\u{ Non-surrogate }"); assert(/(?<\u{0041}>.)/u.test("a"), "\\u{ Non-surrogate }");
assert(/(?<a\u{104A4}>.)/u.test("a"), "\\u{ Surrogate, ID_Continue }"); assert(/(?<a\u{104A4}>.)/u.test("a"), "\\u{ Surrogate, ID_Continue }");
assert.throws(SyntaxError, () => eval("/(?<a\\u{110000}>.)/u"), "\\u{ Out-of-bounds ");
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/u"), "Lea");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/u"), "Trai");
assert(RegExp("(?<\u{0041}>.)", "u").test("a"), "Non-surrogate"); assert(RegExp("(?<\u{0041}>.)", "u").test("a"), "Non-surrogate");
assert(RegExp("(?<a\u{104A4}>.)", "u").test("a"), "Surrogate,ID_Continue"); assert(RegExp("(?<a\u{104A4}>.)", "u").test("a"), "Surrogate,ID_Continue");
// Bracketed escapes are not allowed;
// 4-char escapes must be the proper ID_Start/ID_Continue
assert.throws(SyntaxError, () => eval("/(?<a\\uD801>.)/u"), "Lead");
assert.throws(SyntaxError, () => eval("/(?<a\\uDCA4>.)/u"), "Trail");
assert((/(?<\u{0041}>.)/u).test("a"), "Non-surrogate"); assert((/(?<\u{0041}>.)/u).test("a"), "Non-surrogate");
assert(/(?<a\u{104A4}>.)/u.test("a"), "Surrogate, ID_Continue"); assert(/(?<a\u{104A4}>.)/u.test("a"), "Surrogate, ID_Continue");
assert(RegExp("(?<\\u0041>.)", "u").test("a"), "Non-surrogate"); assert(RegExp("(?<\\u0041>.)", "u").test("a"), "Non-surrogate");
// Backslash is not allowed as ID_Start and ID_Continue
assert.throws(SyntaxError, () => eval("/(?<\\>.)/u"), "'\' misclassified as ID_Start");
assert.throws(SyntaxError, () => eval("/(?<a\\>.)/u"), "'\' misclassified as ID_Continue");

View File

@ -0,0 +1,10 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named groups can be forward references.
esid: sec-atomescape
features: [regexp-named-groups]
---*/
assert(/\k<a>(?<a>x)/.test("x"));

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)\k<ab>/u;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)\k<ab>/;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<ab>a)\k<a>/u;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<ab>a)\k<a>/;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a>(?<ab>a)/u;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a>(?<ab>a)/;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a>(?<b>x)/;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<b>/u;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a>/u;

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Group reference must have corresponding group.
info: |
It is a Syntax Error if the enclosing Pattern does not contain a
GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue
equals the StringValue of the RegExpIdentifierName of this production's
GroupName.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<b>/;

View File

@ -0,0 +1,18 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifiers must be unique.
info: |
It is a Syntax Error if Pattern contains multiple GroupSpecifiers
whose enclosed RegExpIdentifierNames have the same StringValue.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)(?<b>b)(?<a>a)/u;

View File

@ -0,0 +1,18 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifiers must be unique.
info: |
It is a Syntax Error if Pattern contains multiple GroupSpecifiers
whose enclosed RegExpIdentifierNames have the same StringValue.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)(?<b>b)(?<a>a)/;

View File

@ -0,0 +1,18 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifiers must be unique.
info: |
It is a Syntax Error if Pattern contains multiple GroupSpecifiers
whose enclosed RegExpIdentifierNames have the same StringValue.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)(?<a>a)/u;

View File

@ -0,0 +1,18 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifiers must be unique.
info: |
It is a Syntax Error if Pattern contains multiple GroupSpecifiers
whose enclosed RegExpIdentifierNames have the same StringValue.
esid: sec-patterns-static-semantics-early-errors
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>a)(?<a>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>\a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<a/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<a/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<>/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k<>/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a(?<a>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a(?<a>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k(?<a>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<>/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/\k<a/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupName is `< RegExpIdentifierName >`.
esid: prod-GroupName
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a>.)\k/;

View File

@ -0,0 +1,13 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Lone surrogates in RegExp group names
esid: prod-GroupSpecifier
features: [regexp-named-groups]
---*/
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lead");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trail");
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/u"), "Lead with u flag");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/u"), "Trail with u flag");

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\>.)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<$𐒤>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<𐒤>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<𐒤>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\uD801\uDCA4>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\uD801>.)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\uD801>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\uDCA4>.)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\uDCA4>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\u{104A4}>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\u{10FFFF}>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<\>.)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<\>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a\u{110000}>.)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<❤>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<❤>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<42a>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<42a>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<:a>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<:a>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a:>a)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<a:>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: \u{} escapes in GroupSpecifier allowed only in Unicode mode
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<\u{03C0}>a)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: \u{} escapes in GroupSpecifier allowed only in Unicode mode
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<\u{0041}>.)/;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<aa)/u;

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: GroupSpecifier must be identifier-like.
esid: prod-GroupSpecifier
negative:
phase: parse
type: SyntaxError
features: [regexp-named-groups]
---*/
throw "Test262: This statement should not be evaluated.";
/(?<aa)/;