diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-08-27 19:23:37 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-08-27 19:26:16 +0200 |
commit | 639751d218ef423efef8e9aa0fa9abaff7122186 (patch) | |
tree | 013aef8a1569c8b87f2ca79e6c6a4fc1358f1fdc /src/testdir | |
parent | cd7293bf6c358bb0e183582a2927fc03566d29f6 (diff) |
patch 9.0.1805: Vim9: problem compiling object method as function call argv9.0.1805
Problem: Vim9: problem compiling object method as function call arg
Solution: After a object/class method call, remove the object/class from
the stack.
closes: #12081
closes: #12929
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_class.vim | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index bfe203289c..f7d6b73f49 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -3391,4 +3391,51 @@ def Test_interface_private_class_method() v9.CheckScriptFailure(lines, 'E1349: Function "_Foo" of interface "Intf" not implemented') enddef +" Test for using the return value of a class/object method as a function +" argument. +def Test_objmethod_funcarg() + var lines =<< trim END + vim9script + + class C + def Foo(): string + return 'foo' + enddef + endclass + + def Bar(a: number, s: string): string + return s + enddef + + def Baz(c: C) + assert_equal('foo', Bar(10, c.Foo())) + enddef + + var t = C.new() + Baz(t) + END + v9.CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + + class C + static def Foo(): string + return 'foo' + enddef + endclass + + def Bar(a: number, s: string): string + return s + enddef + + def Baz() + assert_equal('foo', Bar(10, C.Foo())) + enddef + + Baz() + END + v9.CheckScriptSuccess(lines) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |