Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
silverwind opened this issue Jul 22, 2017 · 7 comments
Closed

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

silverwind opened this issue Jul 22, 2017 · 7 comments
Labels
confirmed-bug Issues with confirmed bugs. good first issue Issues that are suitable for first-time contributors. repl Issues and PRs related to the REPL subsystem.

Comments

@silverwind
Copy link
Contributor

silverwind commented Jul 22, 2017

$ node
> ...[]
Invalid REPL keyword

Should instead throw this error:

$ node -p '...[]'
[eval]:1
...[]
^^^
SyntaxError: Unexpected token ...
@silverwind silverwind added good first issue Issues that are suitable for first-time contributors. repl Issues and PRs related to the REPL subsystem. labels Jul 22, 2017
@shivanth
Copy link
Contributor

I take this up ...

shivanth added a commit to shivanth/node that referenced this issue Jul 23, 2017
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword

Fixes: nodejs#14426
@shivanth
Copy link
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 ?

@refack
Copy link
Contributor

refack commented Jul 23, 2017

@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

@refack
Copy link
Contributor

refack commented Jul 23, 2017

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

@Fishrock123 Fishrock123 added the confirmed-bug Issues with confirmed bugs. label Jul 24, 2017
@shivanth
Copy link
Contributor

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

@refack
Copy link
Contributor

refack commented Jul 24, 2017

@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}}
...

@silverwind
Copy link
Contributor Author

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.

addaleax pushed a commit that referenced this issue Jul 29, 2017
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: #14426
PR-URL: #14467
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
shivanth added a commit to shivanth/node that referenced this issue Aug 18, 2017
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: nodejs#14426
PR-URL: nodejs#14467
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
MylesBorins pushed a commit that referenced this issue Sep 19, 2017
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: #14426
Backport-PR-URL: #14915
PR-URL: #14467
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. good first issue Issues that are suitable for first-time contributors. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants