patch 8.2.0467: Vim9: some errors are not tested
Problem: Vim9: some errors are not tested
Solution: Add more tests. Fix that Vim9 script flag is not reset.
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index d67c2d5..c9d5024 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -812,12 +812,25 @@
call CheckDefExecFailure("echo s:doesnt_exist", 'E121:')
call CheckDefExecFailure("echo g:doesnt_exist", 'E121:')
+ call CheckDefFailure("echo a:somevar", 'E1075:')
+ call CheckDefFailure("echo l:somevar", 'E1075:')
+ call CheckDefFailure("echo x:somevar", 'E1075:')
+
+ " TODO
+ call CheckDefFailure("echo b:somevar", 'not supported yet')
+ call CheckDefFailure("echo w:somevar", 'not supported yet')
+ call CheckDefFailure("echo t:somevar", 'not supported yet')
+
call CheckDefExecFailure("let x = +g:astring", 'E1030:')
call CheckDefExecFailure("let x = +g:ablob", 'E974:')
call CheckDefExecFailure("let x = +g:alist", 'E745:')
call CheckDefExecFailure("let x = +g:adict", 'E728:')
call CheckDefFailureMult(["let x = ''", "let y = x.memb"], 'E715:')
+
+ call CheckDefExecFailure("[1, 2->len()", 'E492:')
+ call CheckDefExecFailure("#{a: 1->len()", 'E488:')
+ call CheckDefExecFailure("{'a': 1->len()", 'E492:')
endfunc
let g:Funcrefs = [function('add')]
@@ -878,4 +891,8 @@
call CheckDefFailure("v:nosuch += 3", 'E1001:')
call CheckDefFailure("let v:version = 3", 'E1064:')
call CheckDefFailure("let asdf = v:nosuch", 'E1001:')
+
+ call CheckDefFailure("echo len('asdf'", 'E110:')
+ call CheckDefFailure("echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()", 'E1011:')
+ call CheckDefFailure("echo doesnotexist()", 'E117:')
endfunc
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 15b2640..5eeb198 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -101,6 +101,8 @@
call CheckDefFailure(['let true = 1'], 'E1034:')
call CheckDefFailure(['let false = 1'], 'E1034:')
+ call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef'], 'E1050:')
+
call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
@@ -618,6 +620,12 @@
enddef
{'a': 1, 'b': 2}->DictFunc()
assert_equal(#{a: 1, b: 2}, dictvar)
+ def CompiledDict()
+ {'a': 3, 'b': 4}->DictFunc()
+ enddef
+ CompiledDict()
+ assert_equal(#{a: 3, b: 4}, dictvar)
+
#{a: 3, b: 4}->DictFunc()
assert_equal(#{a: 3, b: 4}, dictvar)