mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 22:57:31 +09:00
1340089 - Check the binding name in comprehensionFor.
This commit is contained in:
parent
138d60c071
commit
e3244802ec
2 changed files with 109 additions and 0 deletions
|
|
@ -8101,6 +8101,8 @@ Parser<ParseHandler>::comprehensionFor(GeneratorKind comprehensionKind)
|
||||||
|
|
||||||
MUST_MATCH_TOKEN_FUNC(TokenKindIsPossibleIdentifier, JSMSG_NO_VARIABLE_NAME);
|
MUST_MATCH_TOKEN_FUNC(TokenKindIsPossibleIdentifier, JSMSG_NO_VARIABLE_NAME);
|
||||||
RootedPropertyName name(context, bindingIdentifier(YieldIsKeyword));
|
RootedPropertyName name(context, bindingIdentifier(YieldIsKeyword));
|
||||||
|
if (!name)
|
||||||
|
return null();
|
||||||
if (name == context->names().let) {
|
if (name == context->names().let) {
|
||||||
error(JSMSG_LET_COMP_BINDING);
|
error(JSMSG_LET_COMP_BINDING);
|
||||||
return null();
|
return null();
|
||||||
|
|
|
||||||
107
js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
Normal file
107
js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
var BUGNUMBER = 1340089;
|
||||||
|
var summary = "Comprehension should check the binding names";
|
||||||
|
|
||||||
|
print(BUGNUMBER + ": " + summary);
|
||||||
|
|
||||||
|
// Non strict mode.
|
||||||
|
// Keywords, literals, 'let', and 'yield' are not allowed.
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("[for (true of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("(for (true of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("[for (throw of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("(for (throw of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("[for (let of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("(for (let of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("[for (yield of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
eval("(for (yield of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
eval("[for (public of [1]) 2]");
|
||||||
|
eval("(for (public of [1]) 2)");
|
||||||
|
|
||||||
|
eval("[for (static of [1]) 2]");
|
||||||
|
eval("(for (static of [1]) 2)");
|
||||||
|
|
||||||
|
// Strict mode.
|
||||||
|
// All reserved words are not allowed.
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (true of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (true of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (throw of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (throw of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (let of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (let of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (yield of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (yield of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (public of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (public of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (static of [1]) 2]");
|
||||||
|
}, SyntaxError);
|
||||||
|
assertThrowsInstanceOf(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("(for (static of [1]) 2)");
|
||||||
|
}, SyntaxError);
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
eval("[for (await of [1]) 2]");
|
||||||
|
eval("(for (await of [1]) 2)");
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (typeof reportCompare === "function")
|
||||||
|
reportCompare(true, true);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue