Closed shreevatsa closed 7 years ago
Thanks for the commit and the new release! The is_complete_request
from https://github.com/n-riesco/ijavascript/issues/97 seems to be working perfectly.
About the issue from this report, it seems that the change helps a great deal, in the sense that for various inputs I tried that contain a syntax error, jp-babel doesn't complete the line, which is reasonably clear indication that I need to go back and edit the line to get rid of the errors. So in a sense one could consider this issue solved. However, if I force the input and hit Alt-Enter on a line, then the issue is still present:
~/jupyter/bin/jupyter console --kernel=babel
Jupyter console 5.1.0
jp-babel v1.0.0
https://github.com/n-riesco/jp-babel
In [1]: if (3 == 4) ( console.log('wow'); }
:
:
:
:
:
:
:
:
SyntaxError: unknown: Unexpected token, expected , (1:32)
> 1 | if (3 == 4) ( console.log('wow'); }
| ^
2 |
3 |
4 |
(where I hit Alt-Enter to end the input) and after this, hitting Ctrl-C just shows ^C
in the terminal.
In practice it is not a problem as the user can just avoid hitting Alt-Enter :-)
@shreevatsa I've opened a new issue (see #14), but this issue is unlikely to be fixed, because Babel
's parser doesn't distinguish invalid code from incomplete code (it throws an exception in both cases).
@n-riesco Hmm ok: my report here was more about the fact that after the exception is thrown, control doesn't return to the terminal. I'm not sure it's necessary to distinguish between invalid and incomplete code for that. (E.g. if I hit {
and then Alt-Enter, I guess it counts as incomplete code? but the issue is the same.)
This issue isn't present in IJavascript:
% ~/jupyter/bin/jupyter console --kernel=javascript
Jupyter console 5.1.0
IJavascript v5.0.18
https://github.com/n-riesco/ijavascript
In [1]: {
SyntaxError: Unexpected end of input
at Object.exports.runInThisContext (vm.js:53:16)
at run ([eval]:613:19)
at onRunRequest ([eval]:384:22)
at onMessage ([eval]:352:17)
at emitTwo (events.js:87:13)
at process.emit (events.js:172:7)
at internal/child_process.js:729:12
at nextTickCallbackWith0Args (node.js:489:9)
at process._tickCallback (node.js:418:13)
In [2]: var x = "I can type here";
Out[2]: undefined
(see how I was able to get to [2] and type something). While in jp-babel:
% ~/jupyter/bin/jupyter console --kernel=babel
Jupyter console 5.1.0
jp-babel v1.0.0
https://github.com/n-riesco/jp-babel
In [1]: {
SyntaxError: unknown: Unexpected token (1:1)
> 1 | {
| ^
at Parser.pp$5.raise (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:4373:13)
at Parser.pp.unexpected (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:1716:8)
at Parser.pp$3.parseExprAtom (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3683:12)
at Parser.pp$3.parseExprSubscripts (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3427:19)
at Parser.pp$3.parseMaybeUnary (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3407:19)
at Parser.pp$3.parseExprOps (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3337:19)
at Parser.pp$3.parseMaybeConditional (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3314:19)
at Parser.pp$3.parseMaybeAssign (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3277:19)
at Parser.pp$3.parseExpression (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:3239:19)
at Parser.pp$1.parseStatement (/Users/srajagopalan/jupyter/node_modules/jp-babel/node_modules/babel-core/node_modules/babylon/lib/index.js:1861:19)
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
and the only way out is to kill the process from another shell.
Consider a typo like the following:
and then you can hit Ctrl-C all you like, but nothing works and you basically have to kill the process.
This issue is not present in IJavascript:
where you get back the shell prompt and can fix your typo and continue to work.