comparison 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
comparison
equal deleted inserted replaced
25518:f0de0b105458 25519:f7db86111acd
7019 { 7019 {
7020 type_T *lhs_type = lhs.lhs_member_type; 7020 type_T *lhs_type = lhs.lhs_member_type;
7021 7021
7022 // Special case: assigning to @# can use a number or a 7022 // Special case: assigning to @# can use a number or a
7023 // string. 7023 // string.
7024 if (lhs_type == &t_number_or_string 7024 // Also: can assign a number to a float.
7025 && rhs_type->tt_type == VAR_NUMBER) 7025 if ((lhs_type == &t_number_or_string
7026 || lhs_type == &t_float)
7027 && rhs_type->tt_type == VAR_NUMBER)
7026 lhs_type = &t_number; 7028 lhs_type = &t_number;
7027 if (*p != '=' && need_type(rhs_type, lhs_type, 7029 if (*p != '=' && need_type(rhs_type, lhs_type,
7028 -1, 0, cctx, FALSE, FALSE) == FAIL) 7030 -1, 0, cctx, FALSE, FALSE) == FAIL)
7029 goto theend; 7031 goto theend;
7030 } 7032 }