fix corner case in booleans & conditionals (#5696)
This commit is contained in:
@@ -11592,7 +11592,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
|
|
||||||
function extract_lhs(node, compressor) {
|
function extract_lhs(node, compressor) {
|
||||||
if (node instanceof AST_Assign) return is_lhs_read_only(node.left, compressor) ? node : node.left;
|
if (node instanceof AST_Assign) return is_lhs_read_only(node.left, compressor) ? node : node.left;
|
||||||
if (node instanceof AST_Sequence) return extract_lhs(node.tail_node());
|
if (node instanceof AST_Sequence) return extract_lhs(node.tail_node(), compressor);
|
||||||
if (node instanceof AST_UnaryPrefix && UNARY_POSTFIX[node.operator]) {
|
if (node instanceof AST_UnaryPrefix && UNARY_POSTFIX[node.operator]) {
|
||||||
return is_lhs_read_only(node.expression, compressor) ? node : node.expression;
|
return is_lhs_read_only(node.expression, compressor) ? node : node.expression;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -831,19 +831,36 @@ issue_5469: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5694: {
|
issue_5694_1: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var Infinity;
|
||||||
|
// Node.js v0.12~6 (vm): 42
|
||||||
|
console.log((Infinity = 42) && Infinity);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var Infinity;
|
||||||
|
console.log((Infinity = 42) && Infinity);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5694_2: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var undefined;
|
var undefined;
|
||||||
// Node.js v0.12~6 (vm): 42
|
// Node.js v0.12~6 (vm): NaN
|
||||||
console.log((undefined = 42) && undefined);
|
console.log(("foo", ++undefined) || undefined);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var undefined;
|
var undefined;
|
||||||
console.log((undefined = 42) && undefined);
|
console.log(("foo", ++undefined) || undefined);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user