Skip to content

repl: '...' should not be detected as REPL keyword #14426

Description

@silverwind
$ node
> ...[]
Invalid REPL keyword

Should instead throw this error:

$ node -p '...[]'
[eval]:1
...[]
^^^
SyntaxError: Unexpected token ...

Activity

  1. added
    good first issueIssues that are suitable for first-time contributors.
    replIssues and PRs related to the REPL subsystem.
    on Jul 22, 2017
  2. shivanth commented on Jul 22, 2017

    @shivanth
    Contributor

    I take this up ...

  3. shivanth commented on Jul 23, 2017

    @shivanth
    Contributor

    I've modified REPL so that ... is not considered as a REPL keyword anymore.
    I'm seeing different behviours on REPL of node inspect -p and node. On the inspector I see the expected

    debug> ...[]
    ...[]
    ^^^
    
    SyntaxError: Unexpected token ...
    

    But on node REPL, I see that it's expecting more input

    > ...[]
    ...
    

    What could be the reason ?

  4. refack commented on Jul 23, 2017

    @refack
    Contributor

    @shivanth I'm not sure ...[] is valid expression. [...[]] is...
    The inspect console is a special REPL implemented by node-inspect so it behaves different than the regular REPL. They are both trying to say that ...[] is an invalid expression.

    • chrome
      image
    • cli:
    d:\code\node-cur$ node -e "...[]"
    [eval]:1
    ...[]
    ^^^
    
    SyntaxError: Unexpected token ...
        at createScript (vm.js:74:10)
        at Object.runInThisContext (vm.js:116:10)
        at Object.<anonymous> ([eval]-wrapper:6:22)
        at Module._compile (module.js:569:30)
        at evalScript (bootstrap_node.js:432:27)
        at startup (bootstrap_node.js:139:9)
        at bootstrap_node.js:575:3
    
    d:\code\node-cur$ node -e "(...[])"
    [eval]:1
    (...[])
     ^^^
    
    SyntaxError: Unexpected token ...
        at createScript (vm.js:74:10)
        at Object.runInThisContext (vm.js:116:10)
        at Object.<anonymous> ([eval]-wrapper:6:22)
        at Module._compile (module.js:569:30)
        at evalScript (bootstrap_node.js:432:27)
        at startup (bootstrap_node.js:139:9)
        at bootstrap_node.js:575:3
    
    d:\code\node-cur$ node -e "[...[]]"
    
    d:\code\node-cur$ echo %ERRORLEVEL%
    0
  5. refack commented on Jul 23, 2017

    @refack
    Contributor

    P.S. IMHO what you showed in the comment #14426 (comment) above is the correct behaviour

  6. shivanth commented on Jul 24, 2017

    @shivanth
    Contributor

    @refack , you mean to say that the REPL should wait for more input after seeing ...[] ?

  7. refack commented on Jul 24, 2017

    @refack
    Contributor

    @refack , you mean to say that the REPL should wait for more input after seeing ...[] ?

    I think so... That's how the REPL behaves with invalid expressions:

    > var o = {a:1}}
    ...
    
  8. silverwind commented on Jul 24, 2017

    @silverwind
    ContributorAuthor

    That's how the REPL behaves with invalid expressions

    Which is pretty weird in itself imho, but yes, this seems to be the correct behaviour right now.

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.good first issueIssues that are suitable for first-time contributors.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