@@ -690,12 +690,16 @@ check_number_or_float(vartype_T type1, vartype_T type2, char_u *op)
690690 return OK ;
691691}
692692
693+ /*
694+ * Generate instruction for "+". For a list this creates a new list.
695+ */
693696 static int
694697generate_add_instr (
695698 cctx_T * cctx ,
696699 vartype_T vartype ,
697700 type_T * type1 ,
698- type_T * type2 )
701+ type_T * type2 ,
702+ exprtype_T expr_type )
699703{
700704 garray_T * stack = & cctx -> ctx_type_stack ;
701705 isn_T * isn = generate_instr_drop (cctx ,
@@ -715,7 +719,12 @@ generate_add_instr(
715719 return FAIL ;
716720
717721 if (isn != NULL )
718- isn -> isn_arg .op .op_type = EXPR_ADD ;
722+ {
723+ if (isn -> isn_type == ISN_ADDLIST )
724+ isn -> isn_arg .op .op_type = expr_type ;
725+ else
726+ isn -> isn_arg .op .op_type = EXPR_ADD ;
727+ }
719728
720729 // When concatenating two lists with different member types the member type
721730 // becomes "any".
@@ -769,7 +778,8 @@ generate_two_op(cctx_T *cctx, char_u *op)
769778 switch (* op )
770779 {
771780 case '+' :
772- if (generate_add_instr (cctx , vartype , type1 , type2 ) == FAIL )
781+ if (generate_add_instr (cctx , vartype , type1 , type2 ,
782+ EXPR_COPY ) == FAIL )
773783 return FAIL ;
774784 break ;
775785
@@ -7186,7 +7196,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
71867196 {
71877197 if (generate_add_instr (cctx ,
71887198 operator_type (lhs .lhs_member_type , stacktype ),
7189- lhs .lhs_member_type , stacktype ) == FAIL )
7199+ lhs .lhs_member_type , stacktype ,
7200+ EXPR_APPEND ) == FAIL )
71907201 goto theend ;
71917202 }
71927203 else if (generate_two_op (cctx , op ) == FAIL )
0 commit comments