Mercurial > vim
diff src/vim9compile.c @ 25519:f7db86111acd v8.2.3296
patch 8.2.3296: Vim9: cannot add a number to a float
Commit: https://github.com/vim/vim/commit/af647e76cacc60d3cfc5df3ff5b3d9d4b69b519d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 5 19:01:17 2021 +0200
patch 8.2.3296: Vim9: cannot add a number to a float
Problem: Vim9: cannot add a number to a float.
Solution: Accept a number if the destination is a float. (closes https://github.com/vim/vim/issues/8703)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Aug 2021 19:15:04 +0200 |
parents | 1ac82ad3ee01 |
children | 2063b858cad9 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7021,8 +7021,10 @@ compile_assignment(char_u *arg, exarg_T // Special case: assigning to @# can use a number or a // string. - if (lhs_type == &t_number_or_string - && rhs_type->tt_type == VAR_NUMBER) + // 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)