patch 8.2.1459: Vim9: declaring script var in script does not infer the type
Problem: Vim9: declaring ascript variable at the script level does not
infer the type.
Solution: Get the type from the value. (closes #6716)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 163b948..d8e20e1 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -2914,12 +2914,20 @@
let s:other: number
other = 1234
g:other_var = other
+
+ # type is inferred
+ s:dict = {'a': 222}
+ def GetDictVal(key: any)
+ g:dict_val = s:dict[key]
+ enddef
+ GetDictVal('a')
END
CheckScriptSuccess(lines)
assert_equal('', g:var_uninit)
assert_equal('text', g:var_test)
assert_equal('prefixed', g:var_prefixed)
assert_equal(1234, g:other_var)
+ assert_equal(222, g:dict_val)
unlet g:var_uninit
unlet g:var_test