-
- Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Description
- Version: 8.1.4
- Platform: Darwin Callisto 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
- Subsystem: repl
Calling the undocumented REPLServer.createContext() has unexpected side effects. When the method is called, the value for the server instance's underscoreAssigned and lines properties reset. Here is a reproducible test case.
const repl = require('repl'); const util = require('util'); const assert = require('assert'); const server = repl.start({ prompt: '> ' }); assert.ok(!server.underscoreAssigned); assert.strictEqual(server.lines.length, 0); server.write('_ = 500;\n'); assert.ok(server.underscoreAssigned); assert.strictEqual(server.lines.length, 1); const context = server.createContext(); assert.ok(server.underscoreAssigned); assert.strictEqual(server.lines.length, 1);The overwriting of underscoreAssigned was introduced in ad8257f, while the overwriting of lines is 6 years old at least.
I discovered this when looking for usages of createContext() in the interest of deprecating it and REPLServer.resetContext() for #7619.
Metadata
Metadata
Assignees
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.