Skip to content

Node REPL says "SyntaxError: unexpected symbol :" when parsing multi-line string-keyed objects (e.g. JSON) #21657

@alexch

Description

@alexch
  • Version: 10.3.0 and 10.5.0
  • Platform: MacOS
  • Subsystem: CLI

When entering (or pasting) a multi-line object with string keys -- e.g. any JSON object -- the Node CLI correctly asks for more input with a ... prompt, but then incorrectly fails with a SyntaxError: Unexpected token :.

Example:

$ node --version
v10.3.0
$ node
> {"foo":false}
{ foo: false }
> {
... "foo":false
"foo":false
     ^

SyntaxError: Unexpected token :

This problem only occurs with string keys; bare keys work fine:

> {
... foo:false
... }
{ foo: false }

reproduced on 10.5.0 as well

This is an important issue because JSON objects are all string-keyed, and this parsing bug makes it impossible to copy and paste valid, pretty-printed JSON into the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionIssues related to regressions.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions