isRecoverableError is completely reimplemented using acorn and an
acorn plugin that examines the state of the parser at the time of the
error to determine if the code could be completed on a subsequent line.
PR-URL: https://github.com/nodejs/node/pull/21805
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Previously, the code displayed properties backwards (e.g., showing
prototype properties before own properties). It also did uniqueness
checks during this processing, so these checks were done backwards.
After this change, the properties continue to be displayed backwards,
but the uniqueness checks are done in the proper order.
See also: https://github.com/nodejs/node/issues/21586 which was
discovered during the testing of this fix.
Fixes: https://github.com/nodejs/node/issues/15199
PR-URL: https://github.com/nodejs/node/pull/21588
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This reverts commit 9aa4ec43fc.
This commit in question introduced a regression in repl.eval(),
as the context argument is no longer passed to runInContext().
PR-URL: https://github.com/nodejs/node/pull/20972
Fixes: https://github.com/nodejs/node/issues/20965
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
This aligns these globals with the regular context.
PR-URL: https://github.com/nodejs/node/pull/20717
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Imitate python repl, when the user enters 'exit' or 'quit',
no longer prompt 'Reference Error', but
prompts 'To exit, press ^D or type .exit'.
If the user defines variables named 'exit' or 'quit' ,
only the value of the variables are output
PR-URL: https://github.com/nodejs/node/pull/20617
Fixes: https://github.com/nodejs/node/issues/19021
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This reverts commit b994b8eff6.
This caused regressions in ecosystem code. While the change originally
was semver-major and could be postponed until after Node.js 10,
I think reverting it is a good choice at this point.
Also, I personally do not think defaulting to a shallow inspect
is a bad thing at all – quite the opposite: It makes `util.inspect()`
give an overview of an object, rather than providing a full
display of its contents. Changing the `depth` default to infinity
fundamentally changed the role that `util.inspect()` plays,
and makes output much more verbose and thus at times unusable
for `console.log()`-style debugging.
PR-URL: https://github.com/nodejs/node/pull/20017
Fixes: https://github.com/nodejs/node/issues/19405
Refs: https://github.com/nodejs/node/pull/17907
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
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: https://github.com/nodejs/node/pull/18915
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The magic mode is long deprecated and works the same as the sloppy
mode. Since the sloppy mode is the default, removing the magic mode
should be safe.
PR-URL: https://github.com/nodejs/node/pull/19187
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This is a first batch of updates that touches non-underscored modules in
lib.
PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This is pretty useful when trying to inspect the last
error caught by a REPL, and is made to be analogous to `_`,
which contains the last successful completion value.
PR-URL: https://github.com/nodejs/node/pull/18919
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
When create a nest repl, will register `Runtime.executionContextCreated`
listener to the inspector session.This patch will fix listener
repeatedly register.
PR-URL: https://github.com/nodejs/node/pull/18881
Fixes: https://github.com/nodejs/node/issues/18284
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Number.isNaN is now as fast as `val !== val`. Switch to the more
readable version. Also switch all `isNaN` to `Number.isNaN`.
PR-URL: https://github.com/nodejs/node/pull/18744
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Tests relying on synchronous timing have been migrated to use events.
PR-URL: https://github.com/nodejs/node/pull/17828
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
The current default is not ideal in most use cases. Therefore it is
changed to showing unlimited depth in case util.inspect is called
directly. The default is kept as before for console.log and similar.
Using console.dir will now show a depth of up to five and
console.assert / console.trace will show a unlimited depth.
PR-URL: https://github.com/nodejs/node/pull/17907
Refs: https://github.com/nodejs/node/issues/12693
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Use the V8 inspector protocol, if available, to query the list of
lexically scoped variables (defined with `let`, `const` or `class`).
PR-URL: https://github.com/nodejs/node/pull/16591
Fixes: https://github.com/nodejs/node/issues/983
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The `Object.assign()` calls introduced in commit 90a4390 ("repl: show
proxies as Proxy objects") mutated their first argument, causing the
`{ colors: true }` option from the REPL to leak over into the global
`util.inspect.defaultOptions` object.
Refs: https://github.com/nodejs/node/pull/16485#issuecomment-350428638
PR-URL: https://github.com/nodejs/node/pull/17565
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The initials of expected in TypeError[ERR_INVALID_ARG_TYPE]
are inconsistent. This change is to unify them.
PR-URL: https://github.com/nodejs/node/pull/16401
Fixes: https://github.com/nodejs/node/issues/16383
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Before this commit they transparently invoked their magic methods but
that sometimes throws confusing exceptions with misbehaving proxies.
This change is not wholly uncontroversial but we can always change the
default if necessary. Let's see how it goes.
Fixes: https://github.com/nodejs/node/issues/16483
PR-URL: https://github.com/nodejs/node/pull/16485
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
These are internal only utility functions, CHECK instead of throw
PR-URL: https://github.com/nodejs/node/pull/16544
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Move the throw out of c++ and into js using internal/errors
PR-URL: https://github.com/nodejs/node/pull/16546
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
When `throw undefined` or `throw null` is executed, the REPL crashes.
This change does a check for `null|undefined` before accessing an
error's properties to prevent crashing.
Fixes: https://github.com/nodejs/node/issues/16545
Fixes: https://github.com/nodejs/node/issues/16607
PR-URL: https://github.com/nodejs/node/pull/16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This method is only useful for the internal mechanics of the REPLServer
and does not need to be exposed in user space. It was previously not
documented, so I believe a Runtime deprecation makes sense.
PR-URL: https://github.com/nodejs/node/pull/16242
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Jeremiah Senkpiel <fishrock123@rocketmail.com>
This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.
PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Not used by any callers in `lib/repl.js`, and is not public API.
PR-URL: https://github.com/nodejs/node/pull/16152
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
When a user executes code in the REPLServer which generates an
exception, there is no need to display the REPLServer internal
stack frames.
PR-URL: https://github.com/nodejs/node/pull/15351
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refs: https://github.com/nodejs/node/pull/9601
This slipped through while landing.
PR-URL: https://github.com/nodejs/node/pull/15668
Refs: https://github.com/nodejs/node/pull/15136
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This deprecates the current REPLServer.prototype.turnOffEditorMode
and adds a private function for turnOffEditorMode which handles the
necessary internal changes required instead of having them scattered
about.
PR-URL: https://github.com/nodejs/node/pull/15136
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
The `.load` command would fail with any file that contains
multiline `.` operator expressions. This was particularly
noticeable when chaining promises or multi-line arrow
expressions.
This change Forces the REPL to be in `editorMode` while loading
a file from disk using the `.load` command.
Fixes: https://github.com/nodejs/node/issues/14022
PR-URL: https://github.com/nodejs/node/pull/14861
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
The internal method `REPLServer.createContext()` had
unexpected side effects. When called, the value for the
`underscoreAssigned` and `lines` properties were reset.
This change ensures that those properties are not modified
when a context is created.
Fixes: https://github.com/nodejs/node/issues/14226
Refs: https://github.com/nodejs/node/issues/7619
PR-URL: https://github.com/nodejs/node/pull/14331
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
When autocompleting `require` calls, the repl strips .js file extensions
from results. However, stripping an extension from a directory results
in an error. Update the autocompletion logic to avoid stripping
extensions from directories.
PR-URL: https://github.com/nodejs/node/pull/14727
Fixes: https://github.com/nodejs/node/issues/14726
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
This method does not need to be visible to user code. It has been
undocumented since it was introduced which was perhaps v0.8.9.
The motivation for this change is that the method is simply an
implementation detail of the REPLServer behavior, and does
not need to be exposed to user code.
This change adds documentation of the method with a deprecation
warning, and a test that the method is actually documented.
PR-RUL: https://github.com/nodejs/node/pull/14223
Refs: https://github.com/nodejs/node/issues/7619
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
The `REPLServer.bufferedCommand` property was undocumented, except
for its usage appearing, unexplained, in an example for
`REPLServer.defineCommand`. This commit deprecates that property,
privatizes it, and adds a `REPLServer.clearBufferedCommand()`
function that will clear the buffer.
PR-URL: https://github.com/nodejs/node/pull/13687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <mhdawson@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben.bridgewater@fintura.de>
Refs: https://github.com/nodejs/node/issues/12686
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.
Fixes: https://github.com/nodejs/node/issues/14426
PR-URL: https://github.com/nodejs/node/pull/14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
ESLint 4.x provides stricter indentation linting than previous versions.
In preparation for enabling the stricter indentation linting, adjust the
indentation of four lines in lib/net.js and lib/repl.js.
PR-URL: https://github.com/nodejs/node/pull/14403
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Currently REPL supports autocompletion for core modules and those found
in node_modules. This commit adds tab completion for modules relative
to the current directory.
PR-URL: https://github.com/nodejs/node/pull/14409
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
Previous behavior was to assume an error is a proper error in the
repl module. A check was added to not terminate the process on thrown
repl errors that are `null` or `undefined`.
PR-URL: https://github.com/nodejs/node/pull/14306
Fixes: https://github.com/nodejs/node/issues/12373
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
If the buffer or array is too large to completion, make a dummy smallest
substitute object for it and emit a warning.
PR-URL: https://github.com/nodejs/node/pull/13817
Fixes: https://github.com/nodejs/node/issues/3136
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/13741
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Use non-capturing grouping or remove capturing completely when:
* capturing is useless per se, e.g. in test() check;
* captured groups are not used afterwards at all;
* some of the later captured groups are not used afterwards.
PR-URL: https://github.com/nodejs/node/pull/13718
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* Use existing errors where suitable
* Assign code to a REPL specific error
* Include documentation for the new error code
PR-URL: https://github.com/nodejs/node/pull/11347
Ref: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* Take RegExp creation out of cycles.
* Use test(), not match() in boolean context.
* Remove redundant RegExp parts.
PR-URL: https://github.com/nodejs/node/pull/13536
Reviewed-By: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/13434
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This option has been broken for almost a year when used with any of the
vm.runIn.. family of functions, except for syntax errors.
PR-URL: https://github.com/nodejs/node/pull/13074
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Move the core logic from `LineParser` should fail handling into the
recoverable error check for the REPL default eval.
PR-URL: https://github.com/nodejs/node/pull/6171
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit consists of two changes:
* Avoids returning request/id *just* for the debug() output
* Returns `null` instead of an empty array for the list of paths
PR-URL: https://github.com/nodejs/node/pull/10789
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Using a more "direct" method of function calling yields better
performance.
PR-URL: https://github.com/nodejs/node/pull/10789
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
The workaround used in repl to support `let` and `const` in non-strict
mode (known as "magic" mode) has been unnecessary since V8 v4.9 /
Node.js v6.0.0. This commit doc-deprecate magic mode (which is now
entirely equivalent to sloppy mode) in both `repl` module and in
`internal/repl`, which is responsible for starting the REPL in `node`
interactive mode.
PR-URL: https://github.com/nodejs/node/pull/11599
Refs: https://v8project.blogspot.com/2016/01/v8-release-49.html
Refs: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V6.md#6.0.0
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
This rule enforces new lines around variable declarations. It is
configured to spot only variables that are initialized.
PR-URL: https://github.com/nodejs/node/pull/11462
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The previous commit stores baked-in files with non-ASCII characters
as UTF-16. Replace the \u2019 with a regular quote character so that
the files they're in can be stored as one-byte strings. The UTF-16
functionality is still tested by the Unicode diagram in lib/timers.js.
PR-URL: https://github.com/nodejs/node/pull/11129
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Assigns a static identifier code to all runtime and documentation
only deprecations. The identifier code is included in the emitted
DeprecationWarning.
Also adds a deprecations.md to the API docs to provide a central
location where deprecation codes can be referenced and explained.
PR-URL: https://github.com/nodejs/node/pull/10116
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Add a test to cover situation where REPL is initialized with `useGlobal`
set to `true` and `.clear` is called. This adds coverage for code in
repl.js that is not currently covered.
Includes minor refactor of rocket functions in repl.js for concision.
PR-URL: https://github.com/nodejs/node/pull/10777
Reviewed-By: James M Snell <jasnell@gmail.com>
Formatting changes for upcoming linter update.
PR-URL: https://github.com/nodejs/node/pull/10561
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Previously, autocompletion of scoped packages was not supported by the
repl due to not including the `@` character in the regular expression.
PR-URL: https://github.com/nodejs/node/pull/10296
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This is to be consistent with the other operators and helps
understanding the context when the code is grepped.
PR-URL: https://github.com/nodejs/node/pull/10213
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This improves the heuristic used in multiline-prompt mode to determine
whether a given slash character is at the beginning of a regular
expression.
PR-URL: https://github.com/nodejs/node/pull/10103
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@keybase.io>
Fixes: https://github.com/nodejs/node/issues/9300
Function declarations in the REPL are preprocessed into variable
declarations before being evaluated. However, the preprocessing logic
did not account for the star in a generator function declaration, which
caused the preprocessor to output invalid syntax in some circumstances.
PR-URL: https://github.com/nodejs/node/pull/9852
Fixes: https://github.com/nodejs/node/issues/9850
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
* remove unnecessary backslash (`\`) escaping in regular expressions
* favor `===` over `==`
* multiline arrays indentation consistent with other indentation
PR-URL: https://github.com/nodejs/node/pull/9374
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
the changes are related to https://github.com/nodejs/node/issues/8913
regarding the naming of just the inline anonymous
functions that are not assigned to a variable
PR-URL: https://github.com/nodejs/node/pull/9356
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Instead of writing to the REPL’s input stream for the alignment
spaces in `.editor` mode, let `readline` handle the spaces
properly (echoing them using `_ttyWrite` and adding them to the
current line buffer).
Fixes: https://github.com/nodejs/node/issues/9189
PR-URL: https://github.com/nodejs/node/pull/9207
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
In `.editor` mode, `repl.write()` would have crashed when the
`key` argument was not present, because the overwritten
`_ttyWrite` of REPLs doesn’t check for the absence of a second
argument like `readline.write()` does.
Since the docs indicate that the argument is optional, add
a check paralleling the one in `readline.write()`.
PR-URL: https://github.com/nodejs/node/pull/9207
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
In most cases, named functions match the variable or property to which
they are being assigned. That also seems to be the practice in a series
of PRs currently being evaluated that name currently-anonymous
functions.
This change applies that rule to instances in the code base that don't
comply with that practice.
This will be enforceable with a lint rule once we upgrade to ESLint
3.8.0.
PR-URL: https://github.com/nodejs/node/pull/9113
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This is a known de-opt. It may not be 100% necessary in all cases but it
seems like a decent enough idea to avoid it.
PR-URL: https://github.com/nodejs/node/pull/8873
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
An upcoming custom lint rule will provide slightly more strict
enforcement of argument alignment for multiline function calls. Adjust
existing code to conform.
PR-URL: https://github.com/nodejs/node/pull/8642
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
- Added dots to printed commands.
- Use spaces instead of tabs so there's no misalignment on terminals
with a tab size other than 4.
- Improved the help text for .editor and .help.
- Automatically indent command help based on the longest command.
PR-URL: https://github.com/nodejs/node/pull/8519
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
When in `.editor` mode, current line whitespace prefixes
are preserved in the subsequent line. User can hit backspace
to clean the whitespace
```js
node 🙈 ₹ node
> .editor
// Entering editor mode (^D to finish, ^C to cancel)
function test() {
console.log('tested!'); //On enter, cursor will be after 2 spaces
_
```
PR-URL: https://github.com/nodejs/node/pull/8241
Reviewed-By: James M Snell <jasnell@gmail.com>
This reverts commit fce4b981ea.
This was a breaking change and should have been marked semver-major.
The change that was made altered the output of util.format() and
util.inspect(). With how much those are used in the wild, this type of
change deserves more justification.
Fixes: https://github.com/nodejs/node/issues/8138
PR-URL: https://github.com/nodejs/node/pull/8143
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
`\n` is not enough for Linux with some custom stream
add carriage returns to ensure that the output is displayed correctly
using `\r\n` should not be a problem, even on non-Windows platforms.
Fixes: https://github.com/nodejs/node/issues/7954
PR-URL: https://github.com/nodejs/node/pull/8028
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Disable Windows support for interrupting REPL commands using
Ctrl+C by default, because the switches from console raw mode
and back have been interfering with printing the results of
evaluated expressions.
This is a temporary measure, since the underlying problem is
very likely not related to this specific feature.
Ref: https://github.com/nodejs/node/issues/7837
PR-URL: https://github.com/nodejs/node/pull/7977
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
PR-URL: https://github.com/nodejs/node/pull/7829
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
```js
node 🙈 ₹ git:(upstream ⚡ display-error-repl) ./node
> var 4;
var 4;
^
SyntaxError: Unexpected number
>
```
PR-URL: https://github.com/nodejs/node/pull/7589
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
When `useGlobal` is false, tab completion in the repl does not enumerate
global properties. Instead of just setting these properties blindly on
the global context, e.g.
context[prop] = global[prop]
Use `Object.defineProperty` and the property descriptor found on
`global` for the new property in `context`.
Also addresses a previously unnoticed issue where `console` is writable
when `useGlobal` is false.
If the binary has been built with `./configure --without-intl` then the
`Intl` builtin type will not be available in a repl runtime. Check for
this in the test.
Fixes: https://github.com/nodejs/node/issues/7353
PR-URL: https://github.com/nodejs/node/pull/7369
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Previously, one would have to call setPrompt after calling
rl.createInterface. Now, the prompt string can be set by passing the
prompt property.
PR-URL: https://github.com/nodejs/node/pull/7125
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
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: https://github.com/nodejs/node/pull/7104
Fixes: https://github.com/nodejs/node/issues/3611
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In preparation for stricter linting, remove extra spaces.
PR-URL: https://github.com/nodejs/node/pull/6645
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
Instead of changing the way “simple” expressions are detected,
switch to ignoring errors when completing. This approach is more
generic than the previous one from 0b66b8f2d, but also changes
the way errors are thrown when completing.
This reverts the code changes from commit 0b66b8f2d2.
The test case is left intact.
Fixes: https://github.com/nodejs/node/issues/6325
PR-URL: https://github.com/nodejs/node/pull/6328
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Correct alignment on variable assignments that span multiple lines in
preparation for lint rule to enforce such alignment.
PR-URL: https://github.com/nodejs/node/pull/6242
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Make the builtin libraries available for the `--eval` and
`--print` CLI options, using the same mechanism that the
REPL uses.
This renders workarounds like `node -e 'require("fs").doStuff()'`
unnecessary.
As part of this, the list of builtin modules and the code for
adding the corresponding properties to the target context is moved
to `internal/module.js`, and the previously missing `repl` entry
is added.
PR-URL: https://github.com/nodejs/node/pull/6207
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Change the regular expression that recognizes “simple” JS expressions
to requiring that the full line needs to match it.
Previously, in terms like `a().b.`, `b.` would be a partial match.
This meant that completion would evaluate `b` and either fail with
a `ReferenceError` or, if `b` was some global, return the properties
of the global `b` object.
PR-URL: https://github.com/nodejs/node/pull/6192
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
reduce using RegExp for string test. This pull reuqest replaces
various usages of regular expressions in favor of the ES2015
startsWith and endsWith methods.
PR-URL: https://github.com/nodejs/node/pull/5753
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit addresses https://github.com/nodejs/node/issues/5431 by
changing the way that the repl handles assignment to the global _
variable.
Prior to this commit, node sets the result of the last expression
evaluated in the repl to `_`. This causes problems for users of
underscore, lodash and other packages where it is common to assign
`_` to the package, e.g. `_ = require('lodash');`.
Changes in this commit now result in the following behavior.
- If unassigned on the repl, `_` continues to refer to the last
evaluated expression.
- If assigned, the default behavior of assigning `_` to the last
evaluated expression is disabled, and `_` now references whatever
value was explicitly set. A warning is issued on the repl -
'expression assignment to _ now disabled'.
- If `_` is assigned multiple times, the warning is only displayed once.
- When `.clear` is executed in the repl, `_` continues to refer to its
most recent value, whatever that is (this is per existing behavior).
If `_` had been explicitly set prior to `.clear` it will not change
again with the evaluation of the next expression.
PR-URL: https://github.com/nodejs/node/pull/5535
Fixes: https://github.com/nodejs/node/issues/5431
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
On strict mode, "'use strict'; void 0; " is added as prefix
in order to prevent "use strict" as the result value
for let/const statements. It causes wrong column number in
stack trace.
PR-URL: https://github.com/nodejs/node/pull/5416
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Currently, there is a check to ensure that the user either
provides an object or a string to repl.start(). The string case
is used to set a REPL prompt. However, a default of '> ' already
exists, so forcing the user to specify a prompt is a bit
redundant. This commit removes this restriction.
Fixes: https://github.com/nodejs/node/issues/5385
PR-URL: https://github.com/nodejs/node/pull/5388
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Julian Duque <julianduquej@gmail.com>
Currently, the repl allows multiline function declarations, strings, and
all sorts of niceties by catching the SyntaxErrors they issue and
ignoring them. However, the SyntaxError raised by multiline function
calls was not caught. This commit adds to the whitelist.
PR-URL: https://github.com/nodejs/node/pull/3823
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/5117
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
`match` and `filter` are declared twice with `var` in `repl.js`.
Declare the variables only once.
PR-URL: https://github.com/nodejs/node/pull/4977
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
String#repeat is quite a bit faster than new Array().join().
PR-URL: https://github.com/nodejs/node/pull/3900
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
When loading directory instead of file, no error message
is displayed. It's good to display error message for
this scenario.
PR-URL: https://github.com/nodejs/node/pull/4170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Fix module loading of third-party modules in the REPL by inheriting
module.paths from the REPL's parent module.
Commit ee72ee7 ("module,repl: remove repl require() hack") introduced
a regression where require() of modules in node_modules directories
no longer worked in the REPL (and fortunately only in the REPL.)
It turns out we didn't have test coverage for that but we do now.
Fixes: https://github.com/nodejs/node/issues/4208
PR-URL: https://github.com/nodejs/node/pull/4215
Reviewed-By: Roman Reiss <me@silverwind.io>
When writing multiline input, one can't chain function calls as if the
lines begin with a period, since those are treated as REPL commands.
Before:
> ([0, 1, 2]
... .map(x => x + 1))
Invalid REPL keyword
After:
> ([0, 1, 2]
... .map(x => x + 1))
[ 1, 2, 3 ]
PR-URL: https://github.com/nodejs/node/pull/3835
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Move the method that was added in commit 8ca412b from earlier this month
from lib/util.js to lib/internal/util.js.
Avoids exposing a method that we may not wish to expose just yet, seeing
how it relies on implementation details.
PR-URL: https://github.com/nodejs/node/pull/4026
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Remove a hack that was introduced in commit bb6d468d from November 2010.
This is groundwork for a follow-up commit that makes it possible to use
internal modules in lib/repl.js.
PR-URL: https://github.com/nodejs/node/pull/4026
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Remove util.pump and associated tests
PR-URL: https://github.com/nodejs/node/pull/2531
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
When the user hits `^C` in the REPL show more info about `.exit`.
The idea was to give more info to the user when they hit ^C.
Current version just displays `(^C again to quit)` and most
of the users are not aware of the `.exit` command that would
Exit the repl.
PR-URL: https://github.com/nodejs/node/pull/3368
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit fixes some error messages that are not consistent with
some general rules which most of the error messages follow.
PR-URL: https://github.com/nodejs/node/pull/3374
Reviewed-By: Roman Reiss <me@silverwind.io>
As it is, the comments are not handled properly in REPL. So, if the
comments have `'` or `"`, then they are treated as incomplete string
literals and the error is thrown in REPL.
This patch refactors the existing logic and groups everything in a
class.
Fixes: https://github.com/nodejs/node/issues/3421
PR-URL: https://github.com/nodejs/node/pull/3515
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Emitting 'close' before the history has flushed is somewhat incorrect
and rather confusing.
This also makes the 'close' event always asynchronous for consistency.
Refs: https://github.com/nodejs/node/pull/2356
PR-URL: https://github.com/nodejs/node/pull/3435
Reviewed By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
If a tab completion is attempted on an undefined reference inside of a
function, the REPL was exiting without reporting an error or anything
else. This change results in the REPL reporting the ReferenceError and
continuing.
Fixes: https://github.com/nodejs/node/issues/3346
PR-URL: https://github.com/nodejs/node/pull/3358
Reviewed-By: James M Snell <jasnell@gmail.com>
The actual problem was with the line parsing logic for string literals.
When we use backslash in the string literals, it used to remember the
`\` as the previous character even after we parsed the character next
to it. This leads to REPL thinking that the end of string literals is
not reached.
This patch replaces the previous character with `null`, so that it will
properly skip the character next to it.
Previous Discussion: https://github.com/nodejs/node/pull/2952
Fixes: https://github.com/nodejs/node/issues/2749
PR-URL: https://github.com/nodejs/node/pull/2968
Reviewed-By: Roman Reiss <me@silverwind.io>
This commit replaces instances of io.js with Node.js, based on the
recent convergence. There are some remaining instances of io.js,
related to build and the installer.
Fixes: https://github.com/nodejs/node/issues/2361
PR-URL: https://github.com/nodejs/node/pull/2367
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
Refactored version of https://github.com/joyent/node/pull/25819
Removes integer keys (and keys starting with numbers) from
candidate list on repl tab complete. Refactored the originally
submitted change to simplify and ensure that the integer keys
do not show up on objects either.
Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2409
In REPL, if we evaluate the `RegExp` object's predefined properties,
and if they happen to have the same expression, for example,
> RegExp.$1
'RegExp.$1'
then doing `eval(RegExp.$1)` would evaluate `RegExp.$1` recursively and
eventually throw `RangeError: Maximum call stack size exceeded`.
This patch stores the old values of `RegExp`'s predefined proprties in
an array and restores them just before the current expression entered
by user is evaluated.
Fixes: https://github.com/nodejs/io.js/issues/597
PR-URL: https://github.com/nodejs/io.js/pull/2137
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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'
>
>
>
PR-URL: https://github.com/nodejs/io.js/pull/2163
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
As it is, REPL doesn't honour the line continuation feature very well.
This patch
1. 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.
2. monitors if the line continuation character is used without the
string literal and errors out if that happens.
PR-URL: https://github.com/nodejs/io.js/pull/2163
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
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
>
PR-URL: https://github.com/nodejs/io.js/pull/2163
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
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
>
PR-URL: https://github.com/nodejs/io.js/pull/2163
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If the proxy objects don't have a valid `hasOwnPropertyNames` trap,
REPL crashes with a `TypeError`, as per the bug report
https://github.com/nodejs/io.js/issues/2119
> var proxy = Proxy.create({ fix: function() { return {}; } });
undefined
> proxy.<tab>
TypeError: Proxy handler #<Object> has no 'getOwnPropertyNames' trap
at Function.getOwnPropertyNames (native)
at repl.js:644:40
at REPLServer.defaultEval (repl.js:169:5)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.complete (repl.js:639:14)
at REPLServer.complete [as completer] (repl.js:207:10)
at REPLServer.Interface._tabComplete (readline.js:377:8)
at REPLServer.Interface._ttyWrite (readline.js:845:14)
at ReadStream.onkeypress (readline.js:105:10)
This patch traps the error thrown and suppresses it.
PR-URL: https://github.com/nodejs/io.js/pull/2120
Fixes: https://github.com/nodejs/io.js/issues/2119
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
It's long past v0.3.0 and .break isn't going anywhere anytime soon.
PR-URL: https://github.com/nodejs/io.js/pull/2081
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
It makes no sense to allow people use constants from
`smalloc`, since it will be removed completely eventually.
PR-URL: https://github.com/nodejs/io.js/pull/1822
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
There is no need to check for globals and also check if it is
an array.
PR-URL: https://github.com/nodejs/io.js/pull/1722
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
REPL evaluate `.scope` when it needs to get a list of the variable names
available in the current scope. Do not throw if the output of such
evaluation is not array, just ignore it.
PR-URL: https://github.com/nodejs/io.js/pull/1682
Reviewed-By: Fedor Indutny <fedor@indutny.com>