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
After creating #1141, I had an idea that it might not be the only case where such a change is beneficial.
I think mostly it would be good for when there is a constant with one (or more (#1142)) unary prefixes, which, I believe is pretty common because we usually transform true to !0 and undefined to void 0, which makes expression instanceof AST_Constantfalse.
The main issue here is that I don't quite understand why is_constant() returns false for AST_RegExp:
The main issue here is that I don't quite understand why is_constant() returns false for AST_RegExp:
is_constant is badly named, and it'd be better to think of it as is_primitive. Regexs are instances of the RegExp and have state (particularly lastIndex).
After creating #1141, I had an idea that it might not be the only case where such a change is beneficial.
I think mostly it would be good for when there is a constant with one (or more (#1142)) unary prefixes, which, I believe is pretty common because we usually transform
true
to!0
andundefined
tovoid 0
, which makesexpression instanceof AST_Constant
false
.The main issue here is that I don't quite understand why
is_constant()
returnsfalse
forAST_RegExp
:terser/lib/compress/evaluate.js
Line 109 in 540e886
Here's the commit that introduced this: 0610c02
Might just try doing this anyway and just seeing if any tests fail?
And I'd be glad to work on this.
The text was updated successfully, but these errors were encountered: