@@ -2665,6 +2665,8 @@ parser_pattern_process_assignment (parser_context_t *context_p, /**< context */
26652665 }
26662666 else
26672667 {
2668+ parser_flush_cbc (context_p );
2669+ uint16_t stack_depth_before = context_p -> stack_depth ;
26682670 parser_parse_expression (context_p , PARSE_EXPR_NO_COMMA | PARSE_EXPR_LEFT_HAND_SIDE );
26692671
26702672 if (!PARSER_IS_PUSH_LITERAL (context_p -> last_cbc_opcode ))
@@ -2675,17 +2677,23 @@ parser_pattern_process_assignment (parser_context_t *context_p, /**< context */
26752677 parser_raise_error (context_p , PARSER_ERR_INVALID_DESTRUCTURING_PATTERN );
26762678 }
26772679
2678- if (context_p -> last_cbc_opcode == CBC_PUSH_PROP_THIS_LITERAL )
2679- {
2680- context_p -> last_cbc_opcode = PARSER_CBC_UNAVAILABLE ;
2681- uint16_t lit_index = context_p -> last_cbc .literal_index ;
2682- parser_emit_cbc (context_p , CBC_PUSH_THIS );
2683- parser_emit_cbc_literal (context_p , CBC_PUSH_PROP_LITERAL , lit_index );
2684- }
2685-
26862680 if (end_type == LEXER_RIGHT_SQUARE )
26872681 {
2688- PARSER_PLUS_EQUAL_U16 (rhs_opcode , 1 );
2682+ /* LHS expression parsing may increases the stack depth, therefore rhs opcode may transforms:
2683+ Example: [a.b.c]
2684+ CBC_EXT_ITERATOR_STEP -> CBC_EXT_ITERATOR_STEP_2
2685+ CBC_EXT_REST_INITIALIZER -> CBC_EXT_ITERATOR_STEP_2 */
2686+ uint16_t stack_difference = (uint16_t ) (context_p -> stack_depth - stack_depth_before );
2687+
2688+ if (context_p -> last_cbc_opcode == CBC_PUSH_PROP_LITERAL_LITERAL )
2689+ {
2690+ /* Example: [a.b]
2691+ CBC_EXT_ITERATOR_STEP -> CBC_EXT_ITERATOR_STEP_3
2692+ CBC_EXT_REST_INITIALIZER -> CBC_EXT_ITERATOR_STEP_3 */
2693+ PARSER_PLUS_EQUAL_U16 (stack_difference , 2 );
2694+ }
2695+
2696+ PARSER_PLUS_EQUAL_U16 (rhs_opcode , stack_difference );
26892697 }
26902698 }
26912699 }
0 commit comments