Description
- Version: tested on node v6.2.2 & v6.3.0
- Platform: OS X 10.11.5 on a Mac Mini late 2014, if relevant
- Subsystem: repl
When in the repl in multiline node, specifically when typing a function body, tab completion crashes the repl when invoked on a new line if the previous line would produce an error on evaluating.
Minimal example: (<tab>
indicates pressing the actual tab key)
> function(){
... some_undefined_thing;
... <tab>
repl.js:306
top.outputStream.write((e.stack || e) + '\n');
^
TypeError: Cannot read property 'outputStream' of undefined
at Domain.<anonymous> (repl.js:306:8)
at emitOne (events.js:96:13)
at Domain.emit (events.js:188:7)
at Domain.errorHandler [as _errorHandler] (domain.js:97:23)
at process._fatalException (node.js:247:33)
(Actually, repl.js:306
comes right after the ...
on the line on which tab was pressed.)
Interestingly, this seems to be highly dependent on the exact conditions:
> function(){
... k;
... <tab>
repl.js:306 ...etc (CRASH)...
crashes, just like
> k;
ReferenceError: k is not defined ...etc...
> function(){
... k;
... <tab>
repl.js:306 ...etc (CRASH)...
and
> {k;}
ReferenceError: k is not defined ...etc...
> function(){
... k;
... <tab>
repl.js:306 ...etc (CRASH)...
while
> {
... k;
... }
ReferenceError: k is not defined ...etc...
> function(){
... k;
... <tab>
(opens completions normally)
Another example indicating this isn't something specific to ReferenceErrors:
> function(){
... new Error("");
... <tab>
(opens completions normally)
while
> function(){
... throw new Error("");
... <tab>
repl.js:306 ...etc (CRASH)...
Something else to make things potentially even more mysterious: having the erroring line on the same line as where the block started, doesn't crash.
> function(){ throw new Error("");
... <tab>
(opens completions normally)
while having an extra line in between still crashes:
> function(){
... console.log("hoi");
... throw new Error("");
... <tab>
repl.js:306 ...etc (CRASH)...
I have no idea what might be causing this. Any ideas?