Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
repl: fix auto-complete crash in REPL mode when set env NODE_MODULE_C…
…ONTEXTS=1
  • Loading branch information
abbshr committed Mar 16, 2015
commit fd4fff46c8a4ea47616599cc4c2c6438d1e54234
8 changes: 7 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const debug = util.debuglog('repl');
// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {

// Don't write as `function hasOwnProperty() { ... }`,
// or this custom function will never be executed.
// Because it is overrided by origin `hasOwnProperty`,
// and run origin `hasOwnProperty(anyObject)` directly will always go into crash.
var hasOwnProperty = function (obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

Expand Down Expand Up @@ -667,6 +672,7 @@ REPLServer.prototype.complete = function(line, callback) {
group.sort();
for (var j = 0; j < group.length; j++) {
c = group[j];
// the custom `hasOwnProperty`
if (!hasOwnProperty(uniq, c)) {
completions.push(c);
uniq[c] = true;
Expand Down