GeezerVison is showing github.com — Function redefinition in vm.runInContext · Issue #548 · nodejs/node
Function redefinition in vm.runInContext #548Labels confirmed-bugIssues and PRs for confirmed bugs.vmIssues and PRs related to the vm subsystem. DescriptionPossible bug of iojs or perhaps v8?
var vm = require('vm'), ctx = vm.createContext({});
vm.runInContext('function test(){return 0}', ctx);
vm.runInContext('function test(){return 1}', ctx);
var result = vm.runInContext('test()', ctx);
// returns 0 in io.js, but 1 in node.js
Tested under win7 x64 and linux. ActivityFishrock123 commented on Jan 22, 2015 Confirmed result difference, 0 in iojs and 1 in node (all current versions (0.10.33 & 0.11.15) kyriosli commented on Jan 22, 2015 It seems that a Context is a proxy object in node.js, but a plain object in io.js chrisdickinson commented on Jan 22, 2015 What version of node? Likely this is due to the switch to contextify internally. domenic commented on Jan 22, 2015 This does seem bad, as the intention here is similar to
<script>
function test() { return 0; }
</script>
<script>
function test() { return 1; }
</script>
<script>
alert(test());
</script>
(which alerts 1).
I wonder if it is due to 3c5ea41 Fishrock123 commented on Jan 22, 2015 @domenic not directly / not alone, that commit exists in 0.11.15, which also appears to have the bug. domenic commented on Jan 27, 2015 @Fishrock123 right, I am wondering what the behavior was before that commit but after the contextify switch. piscisaureus commented on Jan 29, 2015 changed the title [-]Function redefination in vm.runInContext[/-] [+]Function redefinition in vm.runInContext[/+] on Feb 5, 2015targos commented on May 24, 2015 Still returning 0 on v2.1.0.
Could be interesting to test on next branch, maybe with #1773 ? Fishrock123 commented on Jun 5, 2015 domenic commented on Jun 5, 2015 Haven't been able to test this with the new patches, but I didn't see any reason why the new patches would necessarily fix it. I still have a list of vm bugs to work on :) brendanashworth commented on Aug 14, 2015 Behavior still occurs in 3.0, marking as a bug! Trott commented on Oct 13, 2015 Still returns 0 in v4.2.0.
MetadataMetadataconfirmed-bugIssues and PRs for confirmed bugs.vmIssues and PRs related to the vm subsystem. DevelopmentNo branches or pull requestsIssue actions
|