@@ -1240,13 +1240,16 @@ generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type)
12401240
12411241/*
12421242 * Generate an ISN_GETITEM instruction with "index".
1243+ * "with_op" is TRUE for "+=" and other operators, the stack has the current
1244+ * value below the list with values.
12431245 */
12441246 static int
1245- generate_GETITEM (cctx_T * cctx , int index )
1247+ generate_GETITEM (cctx_T * cctx , int index , int with_op )
12461248{
12471249 isn_T * isn ;
12481250 garray_T * stack = & cctx -> ctx_type_stack ;
1249- type_T * type = ((type_T * * )stack -> ga_data )[stack -> ga_len - 1 ];
1251+ type_T * type = ((type_T * * )stack -> ga_data )[stack -> ga_len
1252+ - (with_op ? 2 : 1 )];
12501253 type_T * item_type = & t_any ;
12511254
12521255 RETURN_OK_IF_SKIP (cctx );
@@ -1260,7 +1263,8 @@ generate_GETITEM(cctx_T *cctx, int index)
12601263 item_type = type -> tt_member ;
12611264 if ((isn = generate_instr (cctx , ISN_GETITEM )) == NULL )
12621265 return FAIL ;
1263- isn -> isn_arg .number = index ;
1266+ isn -> isn_arg .getitem .gi_index = index ;
1267+ isn -> isn_arg .getitem .gi_with_op = with_op ;
12641268
12651269 // add the item type to the type stack
12661270 if (ga_grow (stack , 1 ) == FAIL )
@@ -6746,19 +6750,17 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
67466750 int is_const = FALSE;
67476751 char_u * wp ;
67486752
6753+ // for "+=", "*=", "..=" etc. first load the current value
6754+ if (* op != '='
6755+ && compile_load_lhs_with_index (& lhs , var_start ,
6756+ cctx ) == FAIL )
6757+ goto theend ;
6758+
67496759 // For "var = expr" evaluate the expression.
67506760 if (var_count == 0 )
67516761 {
67526762 int r ;
67536763
6754- // for "+=", "*=", "..=" etc. first load the current value
6755- if (* op != '=' )
6756- {
6757- if (compile_load_lhs_with_index (& lhs , var_start ,
6758- cctx ) == FAIL )
6759- goto theend ;
6760- }
6761-
67626764 // Compile the expression.
67636765 instr_count = instr -> ga_len ;
67646766 if (incdec )
@@ -6795,7 +6797,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
67956797 {
67966798 // For "[var, var] = expr" get the "var_idx" item from the
67976799 // list.
6798- if (generate_GETITEM (cctx , var_idx ) == FAIL )
6800+ if (generate_GETITEM (cctx , var_idx , * op != '=' ) == FAIL )
67996801 goto theend ;
68006802 }
68016803
0 commit comments