-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Treeshake sequence expression #1650
Treeshake sequence expression #1650
Conversation
- if the test evaluation produces an effect, keep the whole expression - if the test evaluation is unkown but has no effect, remove the expression unless any branch has an effect - if the test evaluation is known, replace the expression with the resulting branch (as before)
Is #1648 a superset of this PR? |
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.
I really like this! No objections to merging this.
@kzc It looks like it but from my side we should merge both anyway. |
@corneliusweig A combined PR would be helpful as it's a bit confusing. Thanks. The individual commits need not be collapsed. |
Looks at each expression in the sequence and only retains the node if it has an effect. Note: in sequence expressions with effects always keep the last node, to be consistent when assigning the resulting value to a variable.
ecf1b89
to
e5eb0ea
Compare
Since this is not a breaking change and I really want this to be in the master before I make my next PR I will merge this now. |
This resolves #1649
The resulting code may have spurious parentheses that wrapped the sequence. For example
var a = (1,2,3)
becomesvar a = (3)
instead ofvar a = 3
. Other than that, all cases covered in #1649 are covered.