diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-27 20:54:41 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-27 20:54:41 +0000 |
commit | 73ade49c4b692e77d2c0b2ef0afbedbf55c5f946 (patch) | |
tree | 1b71849aa638b9678d9a501494d8d82c6a68f4d1 | |
parent | 09ce0b8e1197c85dacf97e75b9b9ac18e0d192df (diff) |
patch 9.0.1107: float constant not recognized as floatv9.0.1107
Problem: Float constant not recognized as float.
Solution: Check the vartype instead of comparing with t_float.
(closes #11754)
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9expr.c | 16 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index faaa915ac9..2c67103c9d 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2045,6 +2045,13 @@ def Test_expr9_number() assert_equal(6, 0x6) assert_equal(15, 0xf) assert_equal(255, 0xff) + + const INFTY = 1.0 / 0.0 + def Test() + assert_equal(1, isinf(INFTY)) + assert_equal(-1, isinf(-INFTY)) + enddef + Test() END v9.CheckDefAndScriptSuccess(lines) enddef diff --git a/src/version.c b/src/version.c index 9c9d02562e..029652e817 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1107, +/**/ 1106, /**/ 1105, diff --git a/src/vim9expr.c b/src/vim9expr.c index 7ec3ee9de7..b4e201eb5b 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -1757,22 +1757,14 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end) --p; if (*p == '-' || *p == '+') { - int negate = *p == '-'; - isn_T *isn; - type_T *type; - - type = get_type_on_stack(cctx, 0); - if (type != &t_float && need_type(type, &t_number, + type_T *type = get_type_on_stack(cctx, 0); + if (type->tt_type != VAR_FLOAT && need_type(type, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL) return FAIL; // only '-' has an effect, for '+' we only check the type - if (negate) - { - isn = generate_instr(cctx, ISN_NEGATENR); - if (isn == NULL) - return FAIL; - } + if (*p == '-' && generate_instr(cctx, ISN_NEGATENR) == NULL) + return FAIL; } else if (numeric_only) { |