patch 9.1.0257: Vim9: :call may not find imported class members
Problem: Vim9: :call may not find imported class members
(mityu)
Solution: Set the typval of an imported lval variable correctly
(Yegappan Lakshmanan)
fixes: #14334
closes: #14386
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index fa1aeb1..8d68f1e 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -2054,6 +2054,13 @@
export def GetText(): string
return 'text'
enddef
+ export var exported_nr: number = 22
+ def AddNum(n: number)
+ exported_nr += n
+ enddef
+ export var exportedDict: dict<func> = {Fn: AddNum}
+ export const CONST = 10
+ export final finalVar = 'abc'
END
writefile(vim9_lines, 'Xvim9_export.vim', 'D')
@@ -2072,6 +2079,13 @@
" imported symbol is script-local
call assert_equal('exported', s:vim9.exported)
call assert_equal('text', s:vim9.GetText())
+ call s:vim9.exportedDict.Fn(5)
+ call assert_equal(27, s:vim9.exported_nr)
+ call call(s:vim9.exportedDict.Fn, [3])
+ call assert_equal(30, s:vim9.exported_nr)
+ call assert_fails('let s:vim9.CONST = 20', 'E46: Cannot change read-only variable "CONST"')
+ call assert_fails('let s:vim9.finalVar = ""', 'E46: Cannot change read-only variable "finalVar"')
+ call assert_fails('let s:vim9.non_existing_var = 20', 'E1048: Item not found in script: non_existing_var')
END
writefile(legacy_lines, 'Xlegacy_script.vim', 'D')