Skip to content

function.sent as an expression statement. #2

@nicolo-ribaudo

Description

@nicolo-ribaudo

Hi, while implementing function.sent support in Babel I got a doubt: is this code valid?

function* foo() {
  function.sent;
}

The current specification disallows it (an ExpressionStatement can't start with function):
https://tc39.github.io/ecma262/#prod-ExpressionStatement

ExpressionStatement[Yield, Await]:
  [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] Expression[+In, ?Yield, ?Await] ;

I couldn't find in this proposal a relaxation of that grammar, but I don't see why it should be disallowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions