comparison src/testdir/test_vim9_expr.vim @ 23555:0f7bb6f706f0 v8.2.2320

patch 8.2.2320: Vim9: no error for comparing bool with string Commit: https://github.com/vim/vim/commit/cff40ff98664f4f5a9631aff1a155caf762ea74b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 9 16:21:37 2021 +0100 patch 8.2.2320: Vim9: no error for comparing bool with string Problem: Vim9: no error for comparing bool with string. Solution: Check for wrong types when comparing. (closes https://github.com/vim/vim/issues/7639)
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Jan 2021 16:30:04 +0100
parents 1bb7fa4f9b35
children 647ff61c0bcd
comparison
equal deleted inserted replaced
23554:c43e824fd305 23555:0f7bb6f706f0
595 595
596 CheckDefFailure(["var x = 'a' == xxx"], 'E1001:', 1) 596 CheckDefFailure(["var x = 'a' == xxx"], 'E1001:', 1)
597 CheckDefFailure(["var x = 'a' == "], 'E1097:', 3) 597 CheckDefFailure(["var x = 'a' == "], 'E1097:', 3)
598 598
599 CheckDefExecFailure(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 4) 599 CheckDefExecFailure(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 4)
600
601 CheckDefExecFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2)
602 CheckDefExecFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2)
603 CheckDefExecFailure(["var x: any = 99", 'echo x == true'], 'E1138', 2)
604 CheckDefExecFailure(["var x: any = 'a'", 'echo x == 99'], 'E1030:', 2)
605
606 for op in ['>', '>=', '<', '<=', '=~', '!~']
607 CheckDefExecFailure([
608 "var a: any = 'a'",
609 'var b: any = true',
610 'echo a ' .. op .. ' b'], 'E1072:', 3)
611 endfor
600 enddef 612 enddef
601 613
602 " test != comperator 614 " test != comperator
603 def Test_expr4_notequal() 615 def Test_expr4_notequal()
604 var lines =<< trim END 616 var lines =<< trim END