You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resolveRedundantLogicalExpressions will test the right hand of the && and conclude that the left hand is redundant as the right hand is always zero.
The result is:
varx=2;console.log(2);
However, the assignment should still be ran.
In general, even if the right hand evaluates to False, the left might have effect.
For example:
functionf(){console.log("Doing important stuff")}varx=2;if(f()&&0){console.log("Not here")}console.log(x)
A good solution would be to, when a constant right hand is found, add the left hand side as a statement just above the if. If it does not have any effect than other modules can optimize it away.
So:
functionf(){console.log("Doing important stuff")}varx=2;f(x)if(false){console.log("Not here")}console.log(x)
in the last example.
PS: as you might notice, I am struggling with some rather evil obfuscation. Sorry for the flood of issues.
The text was updated successfully, but these errors were encountered:
@jorants I really appreciate all the attention you're giving the project 🙏
This is definitely a bug, and the module should verify there are no assignments in the logical expression it looks to resolve.
Consider the following minimal example:
resolveRedundantLogicalExpressions will test the right hand of the && and conclude that the left hand is redundant as the right hand is always zero.
The result is:
However, the assignment should still be ran.
In general, even if the right hand evaluates to False, the left might have effect.
For example:
A good solution would be to, when a constant right hand is found, add the left hand side as a statement just above the if. If it does not have any effect than other modules can optimize it away.
So:
in the last example.
PS: as you might notice, I am struggling with some rather evil obfuscation. Sorry for the flood of issues.
The text was updated successfully, but these errors were encountered: