fix corner case in functions (#3367)

fixes #3366
This commit is contained in:
Alex Lam S.L
2019-04-19 02:55:43 +08:00
committed by GitHub
parent e8a2c0b5bf
commit b55a2fd531
3 changed files with 36 additions and 3 deletions

View File

@@ -73,8 +73,10 @@ exports.run_code = function(code, reuse) {
process.stdout.write = original_write;
if (!reuse || code.indexOf(".prototype") >= 0) {
context = null;
} else for (var key in context) {
delete context[key];
} else {
vm.runInContext(Object.keys(context).map(function(name) {
return "delete " + name;
}).join("\n"), context);
}
}
};