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 raise Exception immediately when it gets naturally invalid multi-line. #3611

Closed
hhsprings opened this issue Oct 30, 2015 · 6 comments
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.

Comments

@hhsprings
Copy link

I'm using v5.0.0 on Windows.

Of course this is invalid as javascript:

a = 3.5e
-5;
console.log(a);

But REPL enters multi-line editting mode:

> a = 3.5e
... 
... 
... .break

We have no way to exit from the mode except .break (or Ctrl-C), and .break will make nothing.

@targos targos added repl Issues and PRs related to the REPL subsystem. confirmed-bug Issues with confirmed bugs. labels Oct 30, 2015
@targos
Copy link
Member

targos commented Oct 30, 2015

confirmed the bug is present in all versions

@targos
Copy link
Member

targos commented Oct 30, 2015

This particular case is not trivial to fix.
REPL goes in multi-line mode because the first line generates a "Unexpected token ILLEGAL" error, which can happen in recoverable cases. See nodejs/node-v0.x-archive#8875.

@Fishrock123
Copy link
Contributor

I think it should be fixable, we should just do extra checks for ; which I feel most people will try to use as a line-ending break-out in this case. Either that or make two enter's break out. Or both.

Fwiw, you can also break out by:

  • Typing a ' or ", which will trigger a syntax error.
  • Typing just ., which will register as an invalid repl command.

@hhsprings
Copy link
Author

I think it should be fixable

Good news.

; which I feel most people will try to use as a line-ending break-out in this case

I think so. I tried it actually.

Either that or make two enter's break out.

I hope this solution if we have no valid two enters.

Typing a ' or ", which will trigger a syntax error.
Typing just ., which will register as an invalid repl command.

Ah, that’s true. And I noticed typing backslash will trigger a syntax error also.

@Trott
Copy link
Member

Trott commented Jun 2, 2016

Proposed fix: #7104

Trott added a commit to Trott/io.js that referenced this issue Jun 4, 2016
Illegal tokens are only recoverable in string literals, RegExp literals,
and block comments. If not in one of these constructs, immediately
return an error rather than giving the user false hope by giving them a
chance to try to recover.

Fixes: nodejs#3611
@Trott Trott closed this as completed in de0aa23 Jun 4, 2016
@Trott
Copy link
Member

Trott commented Jun 4, 2016

#7104 landed so this should be fixed in the next 6.x release (which will be either 6.2.2 or 6.3.0).

evanlucas pushed a commit that referenced this issue Jun 15, 2016
Illegal tokens are only recoverable in string literals, RegExp literals,
and block comments. If not in one of these constructs, immediately
return an error rather than giving the user false hope by giving them a
chance to try to recover.

PR-URL: #7104
Fixes: #3611
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants