@@ -2987,7 +2987,7 @@ func TestMangleUndefined(t *testing.T) {
2987
2987
expectPrintedNormalAndMangle (t , "const x = undefined" , "const x = void 0;\n " , "const x = void 0;\n " )
2988
2988
expectPrintedNormalAndMangle (t , "let x = undefined" , "let x = void 0;\n " , "let x;\n " )
2989
2989
expectPrintedNormalAndMangle (t , "var x = undefined" , "var x = void 0;\n " , "var x = void 0;\n " )
2990
- expectPrintedNormalAndMangle (t , "function foo(a) { if (!a) return undefined; a() }" , "function foo(a) {\n if (!a)\n return void 0;\n a();\n }\n " , "function foo(a) {\n !a || a();\n }\n " )
2990
+ expectPrintedNormalAndMangle (t , "function foo(a) { if (!a) return undefined; a() }" , "function foo(a) {\n if (!a)\n return void 0;\n a();\n }\n " , "function foo(a) {\n a && a();\n }\n " )
2991
2991
2992
2992
// These should not be transformed
2993
2993
expectPrintedNormalAndMangle (t , "delete undefined" , "delete undefined;\n " , "delete undefined;\n " )
@@ -3620,6 +3620,8 @@ func TestMangleReturn(t *testing.T) {
3620
3620
"function x() {\n y && z;\n }\n " )
3621
3621
expectPrintedMangle (t , "function x() { if (y) { if (z) return; w(); } }" ,
3622
3622
"function x() {\n if (y) {\n if (z)\n return;\n w();\n }\n }\n " )
3623
+ expectPrintedMangle (t , "function foo(x) { if (!x.y) {} else return x }" , "function foo(x) {\n if (x.y)\n return x;\n }\n " )
3624
+ expectPrintedMangle (t , "function foo(x) { if (!x.y) return undefined; return x }" , "function foo(x) {\n if (x.y)\n return x;\n }\n " )
3623
3625
3624
3626
// Do not optimize implicit return for statements that care about scope
3625
3627
expectPrintedMangle (t , "function x() { if (y) return; function y() {} }" , "function x() {\n if (y)\n return;\n function y() {\n }\n }\n " )
0 commit comments