Skip to content
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

make is_constant() recognize constants with several unary prefixes #1142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/compress/evaluate.js
Expand Up @@ -109,8 +109,12 @@ AST_Node.DEFMETHOD("is_constant", function () {
return !(this instanceof AST_RegExp);
} else {
return this instanceof AST_UnaryPrefix
&& this.expression instanceof AST_Constant
&& unaryPrefix.has(this.operator);
&& unaryPrefix.has(this.operator)
&& (
// `this.expression` may be an `AST_RegExp`, so not only `.is_constant()`.
this.expression instanceof AST_Constant
|| this.expression.is_constant()
);
}
});

Expand Down