Skip to content

Duktape Bug: yield Incorrectly Treated as Reserved Word in Non-Strict Mode #2581

@Lydia-66

Description

@Lydia-66

BUG Description
In non-strict mode, yield is not a reserved word and can legally be used as an identifier (such as a variable name). Therefore, using yield in a destructuring assignment should be valid according to the ECMAScript specification. However, Duktape throws a syntax error, which suggests this may be a bug in its parser or compliance logic.

Version
Duktape 2.7.0

Command

/home/engines/duktape/duktape-2.7.0/duk

Testcase

var {
    yield = 0
} = {};

Actual Behavior

SyntaxError: invalid variable declaration

Expected Behavior


Specification Reference
According to the ECMAScript 5.1 specification, Section 7.6.1.2 – Future Reserved Words, the identifier yield is considered a future reserved word only when parsing strict mode code. The specification states:

The following are future reserved words when parsing strict mode code:
implements, interface, let, package, private, protected, public, static, and yield.

Implication
This means that in non-strict mode, yield is not a reserved word, and it is valid to use it as an identifier (e.g., a variable name or object property).
https://262.ecma-international.org/5.1/#sec-7.6.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions