diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-22 21:40:33 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-22 21:40:33 +0000 |
commit | 28fbbeac7046f33db350294908eecb380042d553 (patch) | |
tree | 99340cd3f303cfc63059b616e5f6e2b5dcee117f /src/testdir/test_vim9_expr.vim | |
parent | f2f0bddf303e37d4d532ca22e2d53179c20b1d19 (diff) |
patch 8.2.3877: function does not abort after a type error in comparev8.2.3877
Problem: Function does not abort after a type error in compare
Solution: Check getting number fails. (closes #9384)
Diffstat (limited to 'src/testdir/test_vim9_expr.vim')
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 095b969222..259d7722bd 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -675,6 +675,36 @@ def Test_expr4_equal() CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2) CheckDefExecAndScriptFailure(["var x: any = 99", 'echo x == true'], ['E1138', 'E1072:'], 2) CheckDefExecAndScriptFailure(["var x: any = 'a'", 'echo x == 99'], ['E1030:', 'E1072:'], 2) + + lines =<< trim END + vim9script + var n: any = 2 + def Compare() + eval n == '3' + g:notReached = false + enddef + g:notReached = true + Compare() + END + CheckScriptFailure(lines, 'E1030: Using a String as a Number: "3"') + assert_true(g:notReached) + + if has('float') + lines =<< trim END + vim9script + var n: any = 2.2 + def Compare() + eval n == '3' + g:notReached = false + enddef + g:notReached = true + Compare() + END + CheckScriptFailure(lines, 'E892: Using a String as a Float') + assert_true(g:notReached) + endif + + unlet g:notReached enddef def Test_expr4_wrong_type() |