Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update early errors to align with final draft #168

Open
michaelficarra opened this issue Mar 23, 2015 · 1 comment
Open

update early errors to align with final draft #168

michaelficarra opened this issue Mar 23, 2015 · 1 comment
Assignees

Comments

@michaelficarra
Copy link
Member

Especially this section:

// 12.1.1
// It is a Syntax Error if the code matched by this production is contained in strict code and the StringValue of Identifier is "arguments" or "eval".
testParseFailure("'use strict'; arguments = 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; arguments *= 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; [eval] = 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; [,,,eval,] = 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; ({a: eval} = 0)", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; ({a: eval = 0} = 0)", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; [arguments] = 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; [,,,arguments,] = 0", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; ({a: arguments} = 0)", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("'use strict'; ({a: arguments = 0} = 0)", "Assignment to eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; var eval;", "Variable name may not be eval or arguments in strict mode");
testParseFailure("\"use strict\"; var arguments;", "Variable name may not be eval or arguments in strict mode");
testParseFailure("\"use strict\"; let [eval] = 0;", "Variable name may not be eval or arguments in strict mode");
testParseFailure("\"use strict\"; const {a: eval} = 0;", "Variable name may not be eval or arguments in strict mode");
testParseModuleFailure("var eval;", "Variable name may not be eval or arguments in strict mode");
testParseFailure("eval=>0", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("arguments=>0", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("(eval)=>0", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("(arguments)=>0", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; function f(eval){}", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("function f(eval){ \"use strict\"; }", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; !function (eval){}", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("!function (eval){ \"use strict\"; }", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; function* f(eval){}", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("function* f(eval){ \"use strict\"; }", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; !function* (eval){}", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("!function* (eval){ \"use strict\"; }", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("!{ f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("!{ *f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("\"use strict\"; !{ set f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("!{ set f(eval){ \"use strict\"; } };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("class A { f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("class A { *f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
testParseFailure("class A { set f(eval){} };", "Parameter name eval or arguments is not allowed in strict mode");
// It is a Syntax Error if this production has a [Yield] parameter.
// (error)
// It is a Syntax Error if the code match by this production is contained in strict code.
testParseFailure("\"use strict\"; +yield;", "Unexpected token yield");
testParseFailure("\"use strict\"; yield:;", "Unexpected token yield");
testParseFailure("\"use strict\"; var [yield];", "Unexpected token yield");
// It is a Syntax Error if the code match by this production is within the GeneratorBody of a GeneratorMethod, GeneratorDeclaration, or GeneratorExpression.
testParseFailure("function* f(){ function* f(a = +yield){} }", "Unexpected token yield");
testParseFailure("(function* f(){ function* f(a = +yield){} })", "Unexpected token yield");
testParseFailure("!{ *f(){ function* f(a = +yield){} } };", "Unexpected token yield");
// It is a Syntax Error if this production has a [Yield] parameter and StringValue of Identifier is "yield".
// (error)
// It is a Syntax Error if this phrase is contained in strict code and the StringValue of IdentifierName is: "implements", "interface", "let", "package", "private", "protected", "public", "static", or "yield".
testParseFailure("\"use strict\"; +implements;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +interface;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +let;", "Unexpected token let");
testParseFailure("\"use strict\"; +package;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +private;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +protected;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +public;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +static;", "Use of future reserved word in strict mode");
testParseFailure("\"use strict\"; +yield;", "Unexpected token yield");
testParseFailure("package=>0", "Use of future reserved word in strict mode");
testParseFailure("(package)=>0", "Use of future reserved word in strict mode");
testParseFailure("([let])=>0", "Use of future reserved word in strict mode");
testParseFailure("function*a(yield){}", "Unexpected token yield");
testParseFailure("class A {set a(yield){}}", "Unexpected token yield");
// It is a Syntax Error if StringValue of IdentifierName is the same string value as the StringValue of any ReservedWord except for yield.
// (error)

@michaelficarra michaelficarra self-assigned this Mar 23, 2015
@michaelficarra michaelficarra changed the title update early errors to align with latest draft update early errors to align with final draft May 7, 2015
@michaelficarra
Copy link
Member Author

GeneratorParameter has been removed and replaced with additional early errors. /cc @ikarienator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant