Skip to content

Destructuring assignment in REPL throws Uncaught TypeError: Cannot read properties of undefined (reading 'type') #53328

@lukehaas

Description

@lukehaas

Version

20.12.1

Platform

Darwin arm64

Subsystem

No response

What steps will reproduce the bug?

Start the REPL with node, then run this line:

var { ...rest } = await {}

How often does it reproduce? Is there a required condition?

100%

What is the expected behaviour? Why is that the expected behaviour?

No error should be thrown.

What do you see instead?

The following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'type')
    at registerVariableDeclarationIdentifiers (node:internal/repl/await:98:22)
    at node:internal/repl/await:107:15
    at Array.forEach (<anonymous>)
    at registerVariableDeclarationIdentifiers (node:internal/repl/await:106:13)
    at node:internal/repl/await:119:9
    at Array.forEach (<anonymous>)
    at VariableDeclaration (node:internal/repl/await:118:7)
    at visitors.<computed> [as VariableDeclaration] (node:internal/repl/await:147:5)
    at c (node:internal/deps/acorn/acorn-walk/dist/walk:58:37)
    at skipThrough (node:internal/deps/acorn/acorn-walk/dist/walk:186:39)

Additional information

The issue is related to how the REPL handles top-level await.

Metadata

Metadata

Assignees

No one assigned

    Labels

    replIssues and PRs related to the REPL subsystem.

    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