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
If I remember correctly, after reporting that warning, it adds some temporary code to explicitly protect the 1 from being removed. The reason for this is that sometimes an expression that should have no side effects, is actually necessary to workaround a browser bug, e.g. elem.offsetWidth; // force the browser to re-layout
Obviously 1 will never have side effects no matter how buggy your browser is :) so maybe we can make this a little less aggressive.
Since property access is allowed to have side effects, I suppose it should
only aggressively fold for literals, identifiers, function expressions, and
array/object "literals" containing only foldables. Isn't the exact same
judgment needed for identifying dead code?
Hm. Implicit string conversion from an operator might cause `#toString` to
be called, and maybe you're allowed to override toString on primitive
types. But that's a problem for the constant-folder.
(Using https://closure-compiler.appspot.com/home with Advanced Optimizations.)
Currently, the compiler shows a warning:
However, it doesn't (edit:) always constant-fold the comma operator.
This is folded:
This is not:
Output:
The text was updated successfully, but these errors were encountered: