To: vim_dev@googlegroups.com Subject: Patch 8.2.3296 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3296 Problem: Vim9: cannot add a number to a float. Solution: Accept a number if the destination is a float. (closes #8703) Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim *** ../vim-8.2.3295/src/vim9compile.c 2021-08-04 22:30:46.856467289 +0200 --- src/vim9compile.c 2021-08-05 18:47:46.496824939 +0200 *************** *** 7021,7028 **** // Special case: assigning to @# can use a number or a // string. ! if (lhs_type == &t_number_or_string ! && rhs_type->tt_type == VAR_NUMBER) lhs_type = &t_number; if (*p != '=' && need_type(rhs_type, lhs_type, -1, 0, cctx, FALSE, FALSE) == FAIL) --- 7021,7030 ---- // Special case: assigning to @# can use a number or a // string. ! // Also: can assign a number to a float. ! if ((lhs_type == &t_number_or_string ! || lhs_type == &t_float) ! && rhs_type->tt_type == VAR_NUMBER) lhs_type = &t_number; if (*p != '=' && need_type(rhs_type, lhs_type, -1, 0, cctx, FALSE, FALSE) == FAIL) *** ../vim-8.2.3295/src/testdir/test_vim9_assign.vim 2021-08-03 21:16:14.513239986 +0200 --- src/testdir/test_vim9_assign.vim 2021-08-05 18:54:17.719837226 +0200 *************** *** 245,250 **** --- 245,267 ---- END enddef + def Test_float_and_number() + if !has('float') + MissingFeature float + else + var lines =<< trim END + var f: float + f += 2 + f -= 1 + assert_equal(1.0, f) + ++f + --f + assert_equal(1.0, f) + END + CheckDefAndScriptSuccess(lines) + endif + enddef + let g:someNumber = 43 def Test_assign_concat() *** ../vim-8.2.3295/src/version.c 2021-08-05 17:56:03.212718211 +0200 --- src/version.c 2021-08-05 19:00:17.202895198 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3296, /**/ -- Have you heard about the new Barbie doll? It's called Divorce Barbie. It comes with most of Ken's stuff. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///