You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ node -v
v6.10.1-pre
$ uname -a
Linux fox 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ cat s.js
var a = 0;
var i = 5;
do {
try {
} finally {
var NaN = --a;
}
} while (NaN && --i > 0)
console.log(a);
$ node s.js
-5
$ cat s.js | node
-1
$
From mishoo/UglifyJS#1695. I was fuzzing the minifier when I ran into this case. The output when ran from file is different as when ran when piping cli.
The code doesn't seem to do anything in particular that would cause this difference, although redefining NaN could be its own reason.
The text was updated successfully, but these errors were encountered:
It's not a bug so much as it's an artifact of the module system. node s.js wraps the script in a function wrapper where var NaN is a local variable; node < s.js runs it in the global context where it overwrites the global NaN.
If you add a 'use strict' or run node --use_strict < s.js, you can see the difference:
$ out/Release/node --use_strict < tmp/bug12052.js
[stdin]:6
var NaN = --a;
^
TypeError: Cannot assign to read only property 'NaN' of object '#<Object>'
at [stdin]:6:17
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at Object.runInThisContext (vm.js:116:38)
[...]
Version:
v6.10.1-pre
(although this appears to affect multiple versions)
Platform:
Linux fox 4.4.0-64-generic Update README.md #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64
Test case:
Test output:
From mishoo/UglifyJS#1695. I was fuzzing the minifier when I ran into this case. The output when ran from file is different as when ran when piping cli.
The code doesn't seem to do anything in particular that would cause this difference, although redefining
NaN
could be its own reason.The text was updated successfully, but these errors were encountered: