REPL bug fixes
There are four bug fixes.
1. Better line continuation feature
As it is, REPL doesn't honour the line continuation feature very well. This patch
- keeps track of the beginning of the string literals and if they don't end or current line doesn't end with line continuation, then error out.
- monitors if the line continuation character is used without the string literal and errors out if that happens.
undefined
when unknown REPL command is used
2. Removing When an invalid REPL keyword is used, we actually print undefined
as
well in the console.
> process.version
'v2.3.4'
> .invalid_repl_command
Invalid REPL keyword
undefined
>
This patch prevents printing undefined
in this case.
> process.version
'v2.3.5-pre'
> .invalid_repl_command
Invalid REPL keyword
3. preventing REPL crash with inherited properties
When an inherited property is used as a REPL keyword, the REPL crashes.
➜ Desktop iojs
> process.version
'v2.3.4'
> .toString
readline.js:913
stream[ESCAPE_DECODER].next(r[i]);
^
TypeError: Cannot read property 'call' of undefined
at REPLServer.parseREPLKeyword (repl.js:746:15)
at REPLServer.<anonymous> (repl.js:284:16)
at emitOne (events.js:77:13)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
at ReadStream.onkeypress (readline.js:105:10)
at emitTwo (events.js:87:13)
at ReadStream.emit (events.js:172:7)
➜ Desktop
This patch makes the internal commands
object inherit from null
so
that there will be no inherited properties.
> process.version
'v2.3.5-pre'
> .toString
Invalid REPL keyword
>
4. Better empty line handling
In REPL, if we try to evaluate an empty line, we get undefined
.
> process.version
'v2.3.4'
>
undefined
>
undefined
>
This patch prevents undefined
from printing if the string is empty.
> process.version
'v2.3.5-pre'
>
>
>