Skip to content

Lexical Declarations cannot appear after a label #352

Description

@ianwjhalliday

ChakraCore currently allows lexical declarations (let, const, class, function*) to appear after a label. Labels can only prepend a Statement, not a Declaration, according to the ES spec.

See grammar at https://tc39.github.io/ecma262/#sec-ecmascript-language-statements-and-declarations

FunctionDeclaration gets an exception and is allowed, presumably for back-compat. GeneratorDeclaration does not get the exception, however, and so it not allow. See LabelledItem

Async functions presumably will also be disallowed by way of being a HoistableDeclaration and not excepted by LabelledItem.

E.g. each of these lines should be a syntax error but are not currently:

a: let x;
b: const y = 0;
c: class z { }
d: function* w() { }
e: async function u() { } // pending finalization of async function spec

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions