diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-11 18:24:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-11 18:24:46 +0200 |
commit | af8ea0d066d31cf3cd0a39c5c49ce0342728588d (patch) | |
tree | 197127aeed14e316adffce7c854b94bc8351764a /src/testdir/test_vim9_expr.vim | |
parent | 09f067fca38c9f89ad088e8c096c4df3998575e2 (diff) |
patch 8.2.2755: Vim9: no error for using a number in a conditionv8.2.2755
Problem: Vim9: no error for using a number in a condition.
Solution: Also use ISN_COND2BOOL if the type is t_number_bool.
(closes #7644)
Diffstat (limited to 'src/testdir/test_vim9_expr.vim')
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 44ff105c62..0e0e34e01e 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -282,6 +282,20 @@ def Test_expr2() g:vals = [] assert_equal(false, Record(0) || Record(false) || Record(0)) assert_equal([0, false, 0], g:vals) + + g:vals = [] + var x = 1 + if x || true + g:vals = [1] + endif + assert_equal([1], g:vals) + + g:vals = [] + x = 3 + if true || x + g:vals = [1] + endif + assert_equal([1], g:vals) END CheckDefAndScriptSuccess(lines) enddef @@ -357,6 +371,9 @@ def Test_expr2_fails() # TODO: should fail at compile time call CheckDefExecAndScriptFailure(["var x = 3 || 7"], 'E1023:', 1) + call CheckDefAndScriptFailure(["if 3"], 'E1023:', 1) + call CheckDefExecAndScriptFailure(['var x = 3', 'if x', 'endif'], 'E1023:', 2) + call CheckDefAndScriptFailure2(["var x = [] || false"], 'E1012: Type mismatch; expected bool but got list<unknown>', 'E745:', 1) enddef |