Skip to content

Commit

Permalink
fix corner case in comparisons (#3414)
Browse files Browse the repository at this point in the history
fixes #3413
  • Loading branch information
alexlamsl committed May 14, 2019
1 parent f87caac commit 1f0def1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress.js
Expand Up @@ -2348,7 +2348,7 @@ merge(Compressor.prototype, {
case "&&":
return this.left.is_defined(compressor) && this.right.is_defined(compressor);
case "||":
return this.left.is_defined(compressor) || this.right.is_defined(compressor);
return this.left.is_truthy() || this.right.is_defined(compressor);
default:
return true;
}
Expand All @@ -2368,7 +2368,7 @@ merge(Compressor.prototype, {
if (this.is_immutable()) return true;
var fixed = this.fixed_value();
if (!fixed) return false;
this.is_defined = return_true;
this.is_defined = return_false;
var result = fixed.is_defined(compressor);
delete this.is_defined;
return result;
Expand Down
17 changes: 17 additions & 0 deletions test/compress/comparisons.js
Expand Up @@ -380,3 +380,20 @@ unsafe_indexOf: {
}
expect_stdout: "PASS"
}

issue_3413: {
options = {
comparisons: true,
evaluate: true,
side_effects: true,
}
input: {
var b;
void 0 !== ("" < b || void 0) || console.log("PASS");
}
expect: {
var b;
void 0 !== ("" < b || void 0) || console.log("PASS");
}
expect_stdout: "PASS"
}

0 comments on commit 1f0def1

Please sign in to comment.