File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -2881,6 +2881,7 @@ merge(Compressor.prototype, {
2881
2881
if ( ! non_converting_binary [ this . operator ] ) depth ++ ;
2882
2882
var left = this . left . _eval ( compressor , cached , depth ) ;
2883
2883
if ( left === this . left ) return this ;
2884
+ if ( this . operator == ( left ? "||" : "&&" ) ) return left ;
2884
2885
var right = this . right . _eval ( compressor , cached , depth ) ;
2885
2886
if ( right === this . right ) return this ;
2886
2887
var result ;
@@ -3049,7 +3050,10 @@ merge(Compressor.prototype, {
3049
3050
cached . push ( node ) ;
3050
3051
} ) ;
3051
3052
} ) ;
3052
- return stat . value ? stat . value . _eval ( compressor , cached , depth ) : undefined ;
3053
+ if ( ! stat . value ) return undefined ;
3054
+ var val = stat . value . _eval ( compressor , cached , depth ) ;
3055
+ if ( val === stat . value ) return this ;
3056
+ return val ;
3053
3057
} else if ( compressor . option ( "unsafe" ) && exp instanceof AST_PropAccess ) {
3054
3058
var key = exp . property ;
3055
3059
if ( key instanceof AST_Node ) {
Original file line number Diff line number Diff line change @@ -1876,3 +1876,27 @@ issue_3558: {
1876
1876
}
1877
1877
expect_stdout: "1 0"
1878
1878
}
1879
+
1880
+ issue_3568: {
1881
+ options = {
1882
+ evaluate : true ,
1883
+ reduce_vars : true ,
1884
+ toplevel : true ,
1885
+ unsafe : true ,
1886
+ }
1887
+ input: {
1888
+ var a = 0 ;
1889
+ function f ( b ) {
1890
+ return b && b . p ;
1891
+ }
1892
+ console . log ( f ( ++ a + f ( ) ) ) ;
1893
+ }
1894
+ expect: {
1895
+ var a = 0 ;
1896
+ function f ( b ) {
1897
+ return b && b . p ;
1898
+ }
1899
+ console . log ( NaN ) ;
1900
+ }
1901
+ expect_stdout: "NaN"
1902
+ }
You can’t perform that action at this time.
0 commit comments