diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-10 19:42:03 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-10 19:42:03 +0200 |
commit | c323527d67081cfaff22503d1d282495976c7042 (patch) | |
tree | c59f38df837b94ee91d62ab3c7d6cdefe32b5fce /src/testdir | |
parent | fe3418abe0dac65e42e85b5a91c5d0c975bc65bb (diff) |
patch 8.2.3137: Vim9: no error when a line only has a variable namev8.2.3137
Problem: Vim9: no error when a line only has a variable name.
Solution: Give an error when an expression is evaluated without an effect.
(closes #8538)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 19 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 1e99e9568d..79a4ea36e5 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -647,7 +647,7 @@ def Test_expr4_equal() CheckDefFailure(["var x = 'a' == "], 'E1097:', 3) CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2) - CheckDefExecAndScriptFailure2(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 'E1072:', 4) + CheckDefExecAndScriptFailure2(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], 'E691:', 'E1072:', 4) CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2) CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 89cdee7437..08e68d147c 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -2538,7 +2538,7 @@ def Test_restore_modifiers() set eventignore= autocmd QuickFixCmdPost * copen def AutocmdsDisabled() - eval 0 + eval 1 + 2 enddef func Func() noautocmd call s:AutocmdsDisabled() @@ -2551,8 +2551,8 @@ def Test_restore_modifiers() enddef def StackTop() - eval 1 - eval 2 + eval 1 + 2 + eval 2 + 3 # call not on fourth line StackBot() enddef diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 66b0c740fe..b21b63cbe0 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -691,7 +691,7 @@ enddef def Test_cnext_works_in_catch() var lines =<< trim END vim9script - au BufEnter * eval 0 + au BufEnter * eval 1 + 2 writefile(['text'], 'Xfile1') writefile(['text'], 'Xfile2') var items = [ @@ -1754,6 +1754,21 @@ def Test_script_var_shadows_function() CheckScriptFailure(lines, 'E1041:', 5) enddef +def Test_script_var_shadows_command() + var lines =<< trim END + var undo = 1 + undo = 2 + assert_equal(2, undo) + END + CheckDefAndScriptSuccess(lines) + + lines =<< trim END + var undo = 1 + undo + END + CheckDefAndScriptFailure(lines, 'E1207:', 2) +enddef + def s:RetSome(): string return 'some' enddef @@ -2270,7 +2285,7 @@ def Test_if_const_expr() assert_equal(false, res) # with constant "false" expression may be invalid so long as the syntax is OK - if false | eval 0 | endif + if false | eval 1 + 2 | endif if false | eval burp + 234 | endif if false | echo burp 234 'asd' | endif if false |