Skip to content

Commit

Permalink
patch 8.2.3278: Vim9: error when adding 1 to float
Browse files Browse the repository at this point in the history
Problem:    Vim9: error when adding 1 to float.
Solution:   Accept t_number_bool. (closes #8687)
  • Loading branch information
brammool committed Aug 2, 2021
1 parent c316072 commit 7bf9a07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/testdir/test_vim9_assign.vim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ def Test_assignment()
g:inc_counter += 1
assert_equal(2, g:inc_counter)

if has('float')
var f: float
f += 1
assert_equal(1.0, f)
endif

$SOME_ENV_VAR ..= 'more'
assert_equal('somemore', $SOME_ENV_VAR)
CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3278,
/**/
3277,
/**/
Expand Down
3 changes: 2 additions & 1 deletion src/vim9compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -7111,7 +7111,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (
#ifdef FEAT_FLOAT
// If variable is float operation with number is OK.
!(expected == &t_float && stacktype == &t_number) &&
!(expected == &t_float && (stacktype == &t_number
|| stacktype == &t_number_bool)) &&
#endif
need_type(stacktype, expected, -1, 0, cctx,
FALSE, FALSE) == FAIL)
Expand Down

0 comments on commit 7bf9a07

Please sign in to comment.