File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10334,7 +10334,7 @@ merge(Compressor.prototype, {
1033410334 do {
1033510335 node = parent;
1033610336 parent = compressor.parent(level++);
10337- if (parent instanceof AST_Try && parent.bfinally && parent.bfinally !== node ) {
10337+ if (parent instanceof AST_Try && member(node, parent.body) ) {
1033810338 drop = false;
1033910339 break;
1034010340 }
Original file line number Diff line number Diff line change @@ -2046,3 +2046,100 @@ issue_5070: {
20462046 expect_stdout: "PASS"
20472047 node_version: ">=10"
20482048}
2049+
2050+ issue_5157_async_function: {
2051+ options = {
2052+ awaits : true ,
2053+ side_effects : true ,
2054+ }
2055+ input: {
2056+ async function f ( ) {
2057+ throw "FAIL" ;
2058+ }
2059+ ( async function ( ) {
2060+ try {
2061+ return await f ( ) ;
2062+ } catch ( e ) {
2063+ return "PASS" ;
2064+ }
2065+ } ) ( ) . then ( console . log ) ;
2066+ }
2067+ expect: {
2068+ async function f ( ) {
2069+ throw "FAIL" ;
2070+ }
2071+ ( async function ( ) {
2072+ try {
2073+ return await f ( ) ;
2074+ } catch ( e ) {
2075+ return "PASS" ;
2076+ }
2077+ } ) ( ) . then ( console . log ) ;
2078+ }
2079+ expect_stdout: "PASS"
2080+ node_version: ">=8"
2081+ }
2082+
2083+ issue_5157_async_iife: {
2084+ options = {
2085+ awaits : true ,
2086+ side_effects : true ,
2087+ }
2088+ input: {
2089+ ( async function ( ) {
2090+ try {
2091+ return await async function ( ) {
2092+ throw "FAIL" ;
2093+ } ( ) ;
2094+ } catch ( e ) {
2095+ return "PASS" ;
2096+ }
2097+ } ) ( ) . then ( console . log ) ;
2098+ }
2099+ expect: {
2100+ ( async function ( ) {
2101+ try {
2102+ return await async function ( ) {
2103+ throw "FAIL" ;
2104+ } ( ) ;
2105+ } catch ( e ) {
2106+ return "PASS" ;
2107+ }
2108+ } ) ( ) . then ( console . log ) ;
2109+ }
2110+ expect_stdout: "PASS"
2111+ node_version: ">=8"
2112+ }
2113+
2114+ issue_5157_promise: {
2115+ options = {
2116+ awaits : true ,
2117+ side_effects : true ,
2118+ }
2119+ input: {
2120+ var p = new Promise ( function ( resolve , reject ) {
2121+ reject ( "FAIL" ) ;
2122+ } ) ;
2123+ ( async function ( ) {
2124+ try {
2125+ return await p ;
2126+ } catch ( e ) {
2127+ return "PASS" ;
2128+ }
2129+ } ) ( ) . then ( console . log ) ;
2130+ }
2131+ expect: {
2132+ var p = new Promise ( function ( resolve , reject ) {
2133+ reject ( "FAIL" ) ;
2134+ } ) ;
2135+ ( async function ( ) {
2136+ try {
2137+ return await p ;
2138+ } catch ( e ) {
2139+ return "PASS" ;
2140+ }
2141+ } ) ( ) . then ( console . log ) ;
2142+ }
2143+ expect_stdout: "PASS"
2144+ node_version: ">=8"
2145+ }
You can’t perform that action at this time.
0 commit comments