patch 8.2.5026: Vim9: a few lines not covered by tests
Problem: Vim9: a few lines not covered by tests.
Solution: Delete dead code. Add a few test cases. make "12->func()" work.
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index b0ce398..faa4928 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1121,6 +1121,9 @@
var dict4: dict<any> = {one: 1, two: '2'}
var dict5: dict<blob> = {one: 0z01, two: 0z02}
+ # check the type is OK
+ var events: dict<string> = v:event
+
# overwrite
dict3['key'] = 'another'
assert_equal(dict3, {key: 'another'})
@@ -2105,6 +2108,32 @@
va foo = 123
END
v9.CheckDefAndScriptFailure(lines, 'E1065:', 1)
+
+ lines =<< trim END
+ var foo: func(number
+ END
+ v9.CheckDefAndScriptFailure(lines, 'E110:', 1)
+
+ lines =<< trim END
+ var foo: func(number): func(
+ END
+ v9.CheckDefAndScriptFailure(lines, 'E110:', 1)
+
+ for type in ['num_ber',
+ 'anys', 'ani',
+ 'bools', 'boel',
+ 'blobs', 'blub',
+ 'channels', 'channol',
+ 'dicts', 'duct',
+ 'floats', 'floot',
+ 'funcs', 'funk',
+ 'jobs', 'jop',
+ 'lists', 'last'
+ 'numbers', 'numbar',
+ 'strings', 'strung',
+ 'voids', 'viod']
+ v9.CheckDefAndScriptFailure([$'var foo: {type}'], 'E1010:', 1)
+ endfor
enddef
def Test_var_declaration_inferred()
@@ -2118,6 +2147,34 @@
echo GetList()->extend(['x'])
END
v9.CheckScriptFailure(lines, 'E1013:', 6)
+
+ lines =<< trim END
+ vim9script
+ def GetNr(): number
+ return 5
+ enddef
+ def TestOne()
+ var some = [function('len'), GetNr]
+ g:res = typename(some)
+ enddef
+ TestOne()
+ assert_equal('list<func(): number>', g:res)
+
+ def TestTwo()
+ var some = [function('len'), GetNr]
+ g:res = typename(some)
+ enddef
+ TestTwo()
+ assert_equal('list<func(): number>', g:res)
+ unlet g:res
+
+ # FIXME: why is the type different?
+ var first = [function('len'), GetNr]
+ assert_equal('list<func(...): number>', typename(first))
+ var second = [GetNr, function('len')]
+ assert_equal('list<func(...): number>', typename(second))
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_script_local_in_legacy()