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 compress/eval of optional chains #1062
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is looking great in terms of high level structure, but does need a few things changed.
This implements the recursion necessary to determine if a property access/call is part of an optional chain that has short-circuited.
Co-authored-by: Fábio Santos <fabiosantosart@gmail.com>
841d0ce
to
7a9e6e4
Compare
7a9e6e4
to
f76cdb6
Compare
lib/compress/index.js
Outdated
@@ -2436,7 +2432,7 @@ def_optimize(AST_Call, function(self, compressor) { | |||
} | |||
|
|||
var ev = self.evaluate(compressor); | |||
if (ev !== self) { | |||
if (ev !== self && ev !== nullish) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove these checks, by making evaluate
return this
when it sees nullish
.
There's already a bit of a redirection, so it's probably good to take advantage of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, the link doesn't show me where you're pointing. I'm assuming it's the AST_Node.DEFMETHOD("evaluate", …)
definition, so I added a check there.
I asked for just one more little change. This is otherwise looking great, love those tests! |
This is great, thank you 💪 Will release on Monday |
This implements the recursion necessary to determine if a property access/call is part of an optional chain that has short-circuited.
Fixes #1040