Skip to content

Better error message for illegal yield in classic mode #833

Open
@bnoordhuis

Description

@bnoordhuis
async function g() { // note: not a generator function
    yield 42;        // same error message without the semicolon
}

Raises unexpected 'yield' keyword in ESM mode but expecting ';' in classic mode.

It's not strictly wrong because yield is a valid identifier in classic mode (you get the same error with yolo 42) but it's unhelpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions