-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix delete
corner cases
#1799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix delete
corner cases
#1799
Conversation
$ echo 'var a;console.log(delete(a=NaN))' | node
true
$ echo 'var a;console.log(delete(a=NaN))' | bin/uglifyjs -c toplevel
delete NaN;
$ echo 'var a;console.log(delete(a=NaN))' | bin/uglifyjs -c toplevel | node
false |
Looks like |
Because it's rarely used and most coders don't know what it is supposed to return - including me. |
Well, given that we've fixed a lot of the other bugs, I guess there's no harm getting these done and out of the way. I've got a bunch of |
Another
|
- assignment - boolean - conditional - sequence
You've got the same fuzz failures as I did in #1799 (comment) Anyway, should be all fixed up now: $ cat bug2.js
for (var NaN, z = 3; delete (Infinity, NaN) && --z > 0;);
console.log(Infinity, NaN, z);
$ bin/uglifyjs bug2.js -co min.js
WARN: Condition left of && always true [bug2.js:1,21]
$ cat bug2.js | node
Infinity NaN 0
$ cat min.js | node
Infinity NaN 0
$ node bug2.js
Infinity undefined 0
$ node min.js
Infinity undefined 0 Let's see if there are anything left... |
Trying to understand your fix - you dropped the Nope:
|
So we transform it to |
There are never any side effects for a |
Not that I'm aware of:
|
Interesting.
With this PR:
So a |
I'm not the authority on JavaScript, but yeah, feels that way to me. Not even sure why this is allowed in the first place. Though I suppose nobody would go to the trouble of using |
Babbling aside, please give me a signal if you are good with this PR and I'll merge it. |
LGTM |
I believe these |
The other problem is of priority - fuzzer will find bugs, but not necessarily the ones that will affect users the most. And it has a bad habbit of keep hitting the same ones until you fix it (or somehow program the fuzzer to avoid generating such cases) Luckily, we don't seem to have too many cases left after the initial batch. |
It's unavoidable unfortunately - can only guide code generation with probabilities but you can't predict what it will produce. Well at least it will help prevent similar regressions. |
No description provided.