]> granicus.if.org Git - vim/commitdiff
patch 8.2.3278: Vim9: error when adding 1 to float v8.2.3278
authorBram Moolenaar <Bram@vim.org>
Mon, 2 Aug 2021 19:55:15 +0000 (21:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 2 Aug 2021 19:55:15 +0000 (21:55 +0200)
Problem:    Vim9: error when adding 1 to float.
Solution:   Accept t_number_bool. (closes #8687)

src/testdir/test_vim9_assign.vim
src/version.c
src/vim9compile.c

index c104059edac521fe7a648b2558ee82c51248b36c..fa2654801879a1e9e7eecf530b820d85f0905566 100644 (file)
@@ -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:')
index 931a8178575a4f68c2c304a039667fa49463535e..f2aae14a5e654714851f8838a14b0a16753e0c78 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3278,
 /**/
     3277,
 /**/
index c5359fe54df8222f7aa8f4cae02c9c5d67753c72..a487d0065261fc8fc4a15045a97fb6ca01a6b411 100644 (file)
@@ -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)