Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f27f02

Browse filesBrowse files
committed
repl: docs-only deprecation of magic mode
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: #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>
1 parent b77c890 commit 3f27f02
Copy full SHA for 3f27f02

File tree

Expand file treeCollapse file tree

4 files changed

+25
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+25
-11
lines changed
Open diff view settings
Collapse file

‎doc/api/deprecations.md‎

Copy file name to clipboardExpand all lines: doc/api/deprecations.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ Type: Runtime
542542
The `tls.createSecurePair()` API was deprecated in documentation in Node.js
543543
0.11.3. Users should use `tls.Socket` instead.
544544

545+
<a id="DEP0065"></a>
546+
### DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic
547+
548+
Type: Documentation-only
549+
550+
The `repl` module's `REPL_MODE_MAGIC` constant, used for `replMode` option, has
551+
been deprecated. Its behavior has been functionally identical to that of
552+
`REPL_MODE_SLOPPY` since Node.js v6.0.0, when V8 5.0 was imported. Please use
553+
`REPL_MODE_SLOPPY` instead.
554+
555+
The `NODE_REPL_MODE` environment variable is used to set the underlying
556+
`replMode` of an interactive `node` session. Its default value, `magic`, is
557+
similarly deprecated in favor of `sloppy`.
558+
545559
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
546560
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
547561
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Collapse file

‎doc/api/repl.md‎

Copy file name to clipboardExpand all lines: doc/api/repl.md
+8-7Lines changed: 8 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,15 @@ changes:
408408
command before writing to `output`. Defaults to [`util.inspect()`][].
409409
* `completer` {Function} An optional function used for custom Tab auto
410410
completion. See [`readline.InterfaceCompleter`][] for an example.
411-
* `replMode` - A flag that specifies whether the default evaluator executes
412-
all JavaScript commands in strict mode, default mode, or a hybrid mode
413-
("magic" mode.) Acceptable values are:
411+
* `replMode` {symbol} A flag that specifies whether the default evaluator
412+
executes all JavaScript commands in strict mode or default (sloppy) mode.
413+
Acceptable values are:
414414
* `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
415415
* `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is
416416
equivalent to prefacing every repl statement with `'use strict'`.
417-
* `repl.REPL_MODE_MAGIC` - attempt to evaluates expressions in default
418-
mode. If expressions fail to parse, re-try in strict mode.
417+
* `repl.REPL_MODE_MAGIC` - This value is **deprecated**, since enhanced
418+
spec compliance in V8 has rendered magic mode unnecessary. It is now
419+
equivalent to `repl.REPL_MODE_SLOPPY` (documented above).
419420
* `breakEvalOnSigint` - Stop evaluating the current piece of code when
420421
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
421422
with a custom `eval` function. Defaults to `false`.
@@ -461,8 +462,8 @@ environment variables:
461462
- `NODE_REPL_HISTORY_SIZE` - Defaults to `1000`. Controls how many lines of
462463
history will be persisted if history is available. Must be a positive number.
463464
- `NODE_REPL_MODE` - May be any of `sloppy`, `strict`, or `magic`. Defaults
464-
to `magic`, which will automatically run "strict mode only" statements in
465-
strict mode.
465+
to `sloppy`, which will allow non-strict mode code to be run. `magic` is
466+
**deprecated** and treated as an alias of `sloppy`.
466467

467468
### Persistent History
468469

Collapse file

‎lib/internal/repl.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ function createRepl(env, opts, cb) {
3939

4040
opts.replMode = {
4141
'strict': REPL.REPL_MODE_STRICT,
42-
'sloppy': REPL.REPL_MODE_SLOPPY,
43-
'magic': REPL.REPL_MODE_MAGIC
42+
'sloppy': REPL.REPL_MODE_SLOPPY
4443
}[String(env.NODE_REPL_MODE).toLowerCase().trim()];
4544

4645
if (opts.replMode === undefined) {
47-
opts.replMode = REPL.REPL_MODE_MAGIC;
46+
opts.replMode = REPL.REPL_MODE_SLOPPY;
4847
}
4948

5049
const historySize = Number(env.NODE_REPL_HISTORY_SIZE);
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ exports.REPLServer = REPLServer;
633633

634634
exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy');
635635
exports.REPL_MODE_STRICT = Symbol('repl-strict');
636-
exports.REPL_MODE_MAGIC = Symbol('repl-magic');
636+
exports.REPL_MODE_MAGIC = exports.REPL_MODE_SLOPPY;
637637

638638
// prompt is a string to print on each line for the prompt,
639639
// source is a stream to use for I/O, defaulting to stdin/stdout.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.