-
Notifications
You must be signed in to change notification settings - Fork 30k
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: better handling of recoverable errors #18915
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
CI failed but I think those errors are not related to this PR.
https://ci.nodejs.org/job/node-test-commit-linux/nodes=debian8-64/16655/console
https://ci.nodejs.org/job/node-test-commit-linux/nodes=centos7-64/16655/console |
Is this the right place to add other syntax errors that the repl doesn't handle correctly? I can't find an issue for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a nit and a question.
lib/repl.js
Outdated
const pos = frames.findIndex((f) => f.match(/^\s*\^+$/)); | ||
if (pos > 0 && frames[pos - 1].length === frames[pos].length) | ||
return true; | ||
else return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please remove the else. This is a style that is normally not used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebasing and amending to same commit
@@ -163,13 +163,23 @@ const errorTests = [ | |||
send: '.break', | |||
expect: '' | |||
}, | |||
// Template expressions can cross lines | |||
// Template expressions | |||
{ | |||
send: '`io.js ${"1.0"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess recovering from e.g.
'`abc ${ test'
is not possible anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only some forms are not possible. For instance, below one is possible.
`abc ${
test}`
Its mostly consistent with chrome console behaviour except for couple of cases.
- we handle 'missing ) after argument list' error better than chrome console.
- we allow repl commands in multiline mode which should otherwise be treated as properties/functions.
princejwesley@c1796b8 (wip)
> (function() {
... x = { help: () => 'help received' };
... return x
... .help (); <-- no repl command parsing in multiline mode
.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
...
(I'll give PR over the weekend)
@0joshuaolson1 please open a new issue in case you think the repl should recover from errors that you ran into. |
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown.
Landed in ebfa8b1 🎉 |
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. PR-URL: #18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. PR-URL: #18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. PR-URL: #18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. PR-URL: nodejs#18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. PR-URL: nodejs#18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Below syntax errors are handled without force .break/clear - Unexpected Token (prefix errors) - missing ) after argument list In the multiline expression, recoverable errors are truly recoverable, otherwise syntax error will be thrown. Backport-PR-URL: #22380 PR-URL: #18915 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Better handling of recoverable errors in REPL module
Below syntax errors are handled without force .break/clear
In the multiline expression, recoverable errors are truly
recoverable, otherwise syntax error will be thrown.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
repl