-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix corner case in unused
#4913
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
Conversation
What was the relevance of |
Technically your test case is not the same bug − it only fails in That |
Son of a gun - you're right. I thought I originally had a test case that failed on both v3.13.5 and master - but I must have changed it. When I diffed the I attempted to make a test/release script for jquery but it failed to exhibit the bug. It also relied on headless browsers that do not work on my machine, so I abandoned the effort. |
No worries − that's most likely due to #4890 (comment), i.e. I've extended a bug alongside the functionality 😓
After making the same observation, I've stubbed it out: this.addEventListener = function() {
return this;
};
this.document = {
addEventListener: function() {
return this;
},
appendChild: function() {
return this;
},
cloneNode: function() {
return this;
},
createDocumentFragment: function() {
return this;
},
createElement: function() {
return this;
},
documentElement: function() {
return this;
},
nodeType: 9,
setAttribute: function() {
return this;
},
};
this.document.lastChild = this.document;
this.window = this;
this.location = { href: "foo" };
this.module = { exports: {} };
<!-- rest of jquery-2.1.3.js -->
console.log(module.exports.fn.init.prototype === module.exports.fn); Such that: $ cat test.js | node
true $ uglify-js -v
uglify-js 3.13.4
$ uglify-js test.js -c hoist_vars | node
true $ uglify-js -v
uglify-js 3.13.5
$ uglify-js test.js -c hoist_vars | node
false And then let |
The browser stub is quite clever. I tried to run your test case with
Did you experience something different? |
Same experience − remember what we did before I refused to add |
Ah, okay... it runs correctly in the sandbox:
Replacing
But not this way:
How odd. |
I had to feed the reduced test case through test/reduce again to get a small result in a few more minutes. Is there a CLI option to up the max iterations?
So 43 minutes in total to reduce a 9240 line test case. It could be faster, but not bad. Anyway, I'm still astonished that node removal and replacing stuff with 0s and 1s works at all. |
When you do
Nope − but I don't really see the point for doing so. Cascading command line is hardly a lot of effort, and I often do that for
It takes care of the most basic but otherwise tedious details. I intervened between the first and second pass by getting rid of the |
fixes #4912