comparison src/vim9expr.c @ 31549:6f1cbee3d652 v9.0.1107

patch 9.0.1107: float constant not recognized as float Commit: https://github.com/vim/vim/commit/73ade49c4b692e77d2c0b2ef0afbedbf55c5f946 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 27 20:54:41 2022 +0000 patch 9.0.1107: float constant not recognized as float Problem: Float constant not recognized as float. Solution: Check the vartype instead of comparing with t_float. (closes #11754)
author Bram Moolenaar <Bram@vim.org>
date Tue, 27 Dec 2022 22:00:05 +0100
parents 1bebc2093e6b
children 67d9fbe516a3
comparison
equal deleted inserted replaced
31548:0b9737689389 31549:6f1cbee3d652
1755 --p; 1755 --p;
1756 while (VIM_ISWHITE(*p)) 1756 while (VIM_ISWHITE(*p))
1757 --p; 1757 --p;
1758 if (*p == '-' || *p == '+') 1758 if (*p == '-' || *p == '+')
1759 { 1759 {
1760 int negate = *p == '-'; 1760 type_T *type = get_type_on_stack(cctx, 0);
1761 isn_T *isn; 1761 if (type->tt_type != VAR_FLOAT && need_type(type, &t_number,
1762 type_T *type;
1763
1764 type = get_type_on_stack(cctx, 0);
1765 if (type != &t_float && need_type(type, &t_number,
1766 -1, 0, cctx, FALSE, FALSE) == FAIL) 1762 -1, 0, cctx, FALSE, FALSE) == FAIL)
1767 return FAIL; 1763 return FAIL;
1768 1764
1769 // only '-' has an effect, for '+' we only check the type 1765 // only '-' has an effect, for '+' we only check the type
1770 if (negate) 1766 if (*p == '-' && generate_instr(cctx, ISN_NEGATENR) == NULL)
1771 { 1767 return FAIL;
1772 isn = generate_instr(cctx, ISN_NEGATENR);
1773 if (isn == NULL)
1774 return FAIL;
1775 }
1776 } 1768 }
1777 else if (numeric_only) 1769 else if (numeric_only)
1778 { 1770 {
1779 ++p; 1771 ++p;
1780 break; 1772 break;