@@ -4923,18 +4923,19 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
49234923 lvar -> lv_type = stacktype ;
49244924 }
49254925 }
4926- else
4926+ else if ( * op == '=' )
49274927 {
49284928 type_T * use_type = lvar -> lv_type ;
49294929
4930+ // without operator type is here, otherwise below
49304931 if (has_index )
49314932 {
49324933 use_type = use_type -> tt_member ;
49334934 if (use_type == NULL )
49344935 use_type = & t_void ;
49354936 }
49364937 if (need_type (stacktype , use_type , -1 , cctx , FALSE)
4937- == FAIL )
4938+ == FAIL )
49384939 goto theend ;
49394940 }
49404941 }
@@ -5008,18 +5009,20 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
50085009
50095010 if (oplen > 0 && * op != '=' )
50105011 {
5011- type_T * expected = & t_number ;
5012+ type_T * expected ;
50125013 type_T * stacktype ;
50135014
5014- // TODO: if type is known use float or any operation
5015- // TODO: check operator matches variable type
5016-
50175015 if (* op == '.' )
50185016 expected = & t_string ;
5019- else if ( * op == '+' )
5017+ else
50205018 expected = member_type ;
50215019 stacktype = ((type_T * * )stack -> ga_data )[stack -> ga_len - 1 ];
5022- if (need_type (stacktype , expected , -1 , cctx , FALSE) == FAIL )
5020+ if (
5021+ #ifdef FEAT_FLOAT
5022+ // If variable is float operation with number is OK.
5023+ !(expected == & t_float && stacktype == & t_number ) &&
5024+ #endif
5025+ need_type (stacktype , expected , -1 , cctx , FALSE) == FAIL )
50235026 goto theend ;
50245027
50255028 if (* op == '.' )
@@ -5034,20 +5037,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
50345037 member_type , stacktype ) == FAIL )
50355038 goto theend ;
50365039 }
5037- else
5038- {
5039- isn_T * isn = generate_instr_drop (cctx , ISN_OPNR , 1 );
5040-
5041- if (isn == NULL )
5042- goto theend ;
5043- switch (* op )
5044- {
5045- case '-' : isn -> isn_arg .op .op_type = EXPR_SUB ; break ;
5046- case '*' : isn -> isn_arg .op .op_type = EXPR_MULT ; break ;
5047- case '/' : isn -> isn_arg .op .op_type = EXPR_DIV ; break ;
5048- case '%' : isn -> isn_arg .op .op_type = EXPR_REM ; break ;
5049- }
5050- }
5040+ else if (generate_two_op (cctx , op ) == FAIL )
5041+ goto theend ;
50515042 }
50525043
50535044 if (has_index )
0 commit comments