File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6166,9 +6166,10 @@ void EmitDestructuredArray(
61666166 elem = list;
61676167 }
61686168
6169- if (elem->nop == knopEllipsis)
6169+ if (elem->nop == knopEllipsis
6170+ || (elem->nop == knopEmpty && list->nop == knopEmpty))
61706171 {
6171- // Rest must be the last argument - no need to continue .
6172+ // Rest and last empty slot do not require any more processing .
61726173 break ;
61736174 }
61746175
@@ -6190,6 +6191,7 @@ void EmitDestructuredArray(
61906191 break ;
61916192 }
61926193
6194+
61936195 byteCodeGenerator->StartStatement (elem);
61946196
61956197 Js::RegSlot itemLocation = funcInfo->AcquireTmpRegister ();
Original file line number Diff line number Diff line change @@ -581,6 +581,40 @@ var tests = [
581581 }
582582 assert . isTrue ( foo ( ) , "Array destructuring pattern on for..in is initialized correctly" ) ;
583583 }
584+
585+ {
586+ let obj1 = { } ;
587+ obj1 [ Symbol . iterator ] = function ( ) {
588+ return {
589+ next : function ( ) {
590+ assert . fail ( "next function should not be called" ) ;
591+ }
592+ } ;
593+ } ;
594+
595+ // Empty slot should not call next on the iterator.
596+ var [ ] = obj1 ;
597+ }
598+
599+ {
600+ let obj1 = { } ;
601+ obj1 [ Symbol . iterator ] = function ( ) {
602+ return {
603+ next : function ( ) {
604+ this . counter ++ ;
605+ if ( this . counter > 1 )
606+ {
607+ assert . fail ( "next function should not be called for the second time" ) ;
608+ }
609+ return { value : undefined , done : false } ;
610+ } ,
611+ counter : 0
612+ } ;
613+ } ;
614+
615+ // Second empty slot should not call next on the iterator.
616+ var [ , ] = obj1 ;
617+ }
584618
585619 }
586620 }
You can’t perform that action at this time.
0 commit comments