Skip to content

Commit 408de4f

Browse files
committed
lib: the REPL should survive deletion of Array.prototype methods
Specifically, `delete Array.prototype.lastIndexOf` immediately crashes the REPL, as does deletion of a few other Array prototype methods.
1 parent 342b501 commit 408de4f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/domain.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const {
4040
ReflectApply,
4141
SafeMap,
4242
SafeWeakMap,
43+
StringPrototypeRepeat,
4344
Symbol,
4445
} = primordials;
4546

@@ -131,7 +132,7 @@ const domainRequireStack = new Error('require(`domain`) at this point').stack;
131132
const { setUncaughtExceptionCaptureCallback } = process;
132133
process.setUncaughtExceptionCaptureCallback = function(fn) {
133134
const err = new ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE();
134-
err.stack = err.stack + '\n' + '-'.repeat(40) + '\n' + domainRequireStack;
135+
err.stack += `\n${StringPrototypeRepeat('-', 40)}\n${domainRequireStack}`;
135136
throw err;
136137
};
137138

lib/repl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,15 +1526,15 @@ function complete(line, callback) {
15261526
let p;
15271527
if ((typeof obj === 'object' && obj !== null) ||
15281528
typeof obj === 'function') {
1529-
memberGroups.push(filteredOwnPropertyNames(obj));
1529+
ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(obj));
15301530
p = ObjectGetPrototypeOf(obj);
15311531
} else {
15321532
p = obj.constructor ? obj.constructor.prototype : null;
15331533
}
15341534
// Circular refs possible? Let's guard against that.
15351535
let sentinel = 5;
15361536
while (p !== null && sentinel-- !== 0) {
1537-
memberGroups.push(filteredOwnPropertyNames(p));
1537+
ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(p));
15381538
p = ObjectGetPrototypeOf(p);
15391539
}
15401540
} catch {

0 commit comments

Comments
 (0)