Skip to content

Lexical variable declarations (let, const) unusable in repl if error thrown during declaration/first assignment #8309

@polybuildr

Description

@polybuildr
  • Version: v.6.3.1
  • Platform: Linux (Ubuntu 14.04)
  • Subsystem: repl (I think)
let s = Set();

gives TypeError: Constructor Set requires 'new'.

However, after this:

s

gives ReferenceError: s is not defined

and

let s = new Set();

gives TypeError: Identifier 's' has already been declared.

I'm not sure whether this is a real bug or it's expected behaviour, but it sure does seem unusual that s becomes unusable from this point in in the repl.

This isn't a problem when running node on a js file because the TypeError simply terminates execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    replIssues and PRs related to the REPL subsystem.vmIssues and PRs related to the vm 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