@@ -416,22 +416,13 @@ impl<'a> PeepholeOptimizations {
416416 if let Some ( reference_id) = ident. reference_id . get ( ) {
417417 if let Some ( symbol_id) = ctx. scoping ( ) . get_reference ( reference_id) . symbol_id ( ) {
418418 if ctx. state . empty_functions . contains ( & symbol_id) {
419- if e. arguments . is_empty ( ) {
419+ let mut exprs =
420+ Self :: fold_arguments_into_needed_expressions ( & mut e. arguments , ctx) ;
421+ if exprs. is_empty ( ) {
420422 * expr = ctx. ast . void_0 ( e. span ) ;
421423 ctx. state . changed = true ;
422424 return ;
423425 }
424- let mut exprs = ctx. ast . vec ( ) ;
425- for arg in e. arguments . drain ( ..) {
426- match arg {
427- Argument :: SpreadElement ( e) => {
428- exprs. push ( e. unbox ( ) . argument ) ;
429- }
430- match_expression ! ( Argument ) => {
431- exprs. push ( arg. into_expression ( ) ) ;
432- }
433- }
434- }
435426 exprs. push ( ctx. ast . void_0 ( e. span ) ) ;
436427 * expr = ctx. ast . expression_sequence ( e. span , exprs) ;
437428 ctx. state . changed = true ;
@@ -724,8 +715,8 @@ mod test {
724715 test_options ( "var foo = () => {}; foo()" , "" , & options) ;
725716 test_options ( "var foo = () => {}; foo(a)" , "a" , & options) ;
726717 test_options ( "var foo = () => {}; foo(a, b)" , "a, b" , & options) ;
727- test_options ( "var foo = () => {}; foo(...a, b)" , "a , b" , & options) ;
728- test_options ( "var foo = () => {}; foo(...a, ...b)" , "a, b " , & options) ;
718+ test_options ( "var foo = () => {}; foo(...a, b)" , "[...a] , b" , & options) ;
719+ test_options ( "var foo = () => {}; foo(...a, ...b)" , "[...a], [...b] " , & options) ;
729720 test_options ( "var foo = () => {}; x = foo()" , "x = void 0" , & options) ;
730721 test_options ( "var foo = () => {}; x = foo(a(), b())" , "x = (a(), b(), void 0)" , & options) ;
731722 test_options ( "var foo = function () {}; foo()" , "" , & options) ;
0 commit comments