Sitelet https://github.com/nodejs/node/issues/2749
Skip to content

repl: backslashes confuse the multiline parser #2749

Description

@silverwind

Pasting this into the REPL:

function x() {
  return '\n';
}

results in

> function x() {
...   return '\n';
SyntaxError: Unexpected end of input
    at Object.exports.createScript (vm.js:24:10)
    at REPLServer.defaultEval (repl.js:137:25)
    at bound (domain.js:250:14)
    at REPLServer.runBound [as eval] (domain.js:263:12)
    at REPLServer.<anonymous> (repl.js:392:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:210:10)
    at REPLServer.Interface._line (readline.js:546:8)
    at REPLServer.Interface._ttyWrite (readline.js:823:14)

cc: @thefourtheye

Activity

  1. added
    replIssues and PRs related to the REPL subsystem.
    on Sep 9, 2015
  2. thefourtheye commented on Sep 9, 2015

    @thefourtheye
    Contributor

    Mmmm, this is because the readline module parsing \ns as separate lines while parsing the pasted content. I'll look into it today. Glad you spotted it :-)

  3. silverwind commented on Sep 9, 2015

    @silverwind
    ContributorAuthor

    parsing \ns as separate lines

    It's not just \ns, I actually encountered it with a \( first.

  4. silverwind commented on Sep 9, 2015

    @silverwind
    ContributorAuthor

    Looks to be a pretty recent regression, 0.12 works.

  5. thefourtheye commented on Sep 9, 2015

    @thefourtheye
    Contributor

    @silverwind It's after this 81ea52a. Before that the string was accumulated no matter what, till the evaluation of accumulated string is successful. But that commit keeps track of the quotes to detect the string literals.

  6. valenfys commented on Sep 16, 2015

    @valenfys

    Can confirm I got this problem too when trying the hello world server from the website about page in the REPL.

  7. thefourtheye commented on Sep 16, 2015

    @thefourtheye
    Contributor

    @silverwind I think we'll have to revert 81ea52a to fix this problem. cc @Fishrock123

  8. silverwind commented on Sep 18, 2015

    @silverwind
    ContributorAuthor

    👍 for the revert. Being unable to paste any multi-line code containing backslashes warrents it imho.

  9. silverwind commented on Sep 18, 2015

    @silverwind
    ContributorAuthor

    @thefourtheye want to attempt the revert yourself? (We could probably use some documentation for reverting)

  10. added a commit that references this issue on Sep 18, 2015
  11. thefourtheye commented on Sep 18, 2015

    @thefourtheye
    Contributor

    @silverwind Sorry, I was out playing badminton :D Please take a look at the commit log of the bug fix and let me know if that has to be improved.

  12. silverwind commented on Sep 22, 2015

    @silverwind
    ContributorAuthor

    Fixed by fcfd87d

  13. added a commit that references this issue on Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.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