@@ -2046,11 +2046,6 @@ const CORRECTED_CASES = [
20462046 "an assignment nobody reads to an unused name, converting a BigInt beside a Number" ,
20472047 "function f(...r) { r *= 1n; } function g(a) { var b = a; b -= 1n; } try { f(0); console.log('no'); } catch (e) { console.log(e.name); } try { g(1); console.log('no'); } catch (e) { console.log(e.name); }" ,
20482048 { compress : { } , mangle : false }
2049- ] ,
2050- [
2051- "an array destructuring assignment an argument list holds after an assignment or a spread, which V8 refuses bare" ,
2052- "var a = 0, b, c = [1], d = []; function f() {} f((a += 1), ([b] = c)); f([...d, 1], ([b] = c)); console.log(a, b);" ,
2053- { compress : false , mangle : false }
20542049 ]
20552050] ;
20562051
@@ -5954,6 +5949,29 @@ describe("syntax-printer", () => {
59545949 } ) ;
59555950 }
59565951
5952+ it ( "should parenthesize a destructuring assignment V8 refuses bare after another argument" , async ( ) => {
5953+ const { minify, corrections } = await load ( ) ;
5954+ const input =
5955+ "var a = 0, b, c = [1], d = []; function f() {} f((a += 1), ([b] = c)); f([...d, 1], ([b] = c)); console.log(a, b);" ;
5956+ const options = { compress : false , mangle : false } ;
5957+ const { code } = await minify ( input , options ) ;
5958+ expect ( code ) . toContain ( "f(a+=1,([b]=c))" ) ;
5959+ expect ( code ) . toContain ( "f([...d,1],([b]=c))" ) ;
5960+ expect ( runProgram ( /** @type {string } */ ( code ) ) ) . toBe ( runProgram ( input ) ) ;
5961+
5962+ // Other engines read terser's bare output, so only its bytes are compared.
5963+ if ( ! corrections ) throw new Error ( "the correct phase is not installed" ) ;
5964+ corrections . enabled = false ;
5965+ try {
5966+ const uncorrected = await minify ( input , options ) ;
5967+ const reference = await terserReference ( ) . minify ( input , options ) ;
5968+ expect ( uncorrected . code ) . toBe ( reference . code ) ;
5969+ expect ( reference . code ) . toContain ( "f(a+=1,[b]=c)" ) ;
5970+ } finally {
5971+ corrections . enabled = true ;
5972+ }
5973+ } ) ;
5974+
59575975 it ( "should fold a block's function in strict code, or read in its block, as terser does" , async ( ) => {
59585976 const { minify } = await load ( ) ;
59595977 const body =
0 commit comments