[WIP] fix usage of transform() vs optimize()#1593
[WIP] fix usage of transform() vs optimize()#1593alexlamsl wants to merge 4 commits intomishoo:masterfrom
transform() vs optimize()#1593Conversation
test/compress/evaluate.js
Outdated
| evaluate: true, | ||
| } | ||
| input: { | ||
| console.log(typeof void 0 != "undefined"); |
There was a problem hiding this comment.
Please add:
console.log(1 == 1, 1 === 1);
console.log(1 != 1, 1 !== 1);
transform() vs optimize()transform() vs optimize()
07790c7 to
429bbcb
Compare
|
So with the exception of |
|
Prior to this PR, could you explain why the use of |
|
It's basically down to this line Consider whereas calling which was hardcoded prior to #1477. However, that causes other places to have the wrong stack - and while I was working on that PR the bug manifested itself as |
|
That's quite some extensive analysis. In light of all the other scenarios you say had the wrong stack, and the size of this PR, is there sufficient test coverage? |
Nope. I've done convincing myself the code changes are satisfactory just now, and am currently scratching my head about the exact point you've just mentioned. If done right, these tests should also prevent future misuse of |
|
On the bright side, if this PR is done right, then the codebase would be more stable for future additions. I suppoise at the end of the day I'll just have to go through and create a test case for every line changed in |
|
Because this is a rather serious bug, could the one line fix proposed in #1592 (comment) be used as a temporary stop-gap measure until this PR is more thoroughly tested? |
Can you show an example of something that would work with 2.8.11 but break with #1592 (comment) ? |
The stack is all messed up, though I went through all the places where
So AFAICT they all conveniently evaded https://github.com/mishoo/UglifyJS2/blob/b633706ce42576b7e2aa85a96c5691bde87e71ac/lib/compress.js#L3676-L3678 I guess I'll create a new PR with the one-liner just to close #1592, then leave this as the clean-up. |
Given the current `OPT()` node: - `optimize(compressor)` works on the same level, and will only `descend()` if returned instance is different - `transform(compressor)` works on child nodes, and will always `descend()` Other fixes - `loopcontrol_target()` should compare against `compressor.self()` since the current node may have already been displaced - remove obsolete optimisation in `AST_Binary` after mishoo#1477 fixes mishoo#1592
c25a92e to
7550c53
Compare
|
Please don't try to review this PR for now - I'm taking things apart to see what is going on. 😅 |
|
Is this PR obsoleted by recent commits? |
|
@kzc it is - I'm just keeping it around to track the remaining changes for future PRs. I can close it now if this is too much of an eye sore 😅 |
Given the current
OPT()node:optimize(compressor)works on the same level, and will onlydescend()if returned instance is differenttransform(compressor)works on child nodes, and will alwaysdescend()fixes #1592