Mercurial > vim
comparison src/testdir/test_vim9_class.vim @ 33027:669898c9a6c3 v9.0.1805
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Commit: https://github.com/vim/vim/commit/639751d218ef423efef8e9aa0fa9abaff7122186
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Aug 27 19:23:37 2023 +0200
patch 9.0.1805: Vim9: problem compiling object method as function call arg
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 27 Aug 2023 19:30:08 +0200 |
parents | 1d18c7fe609f |
children | 9ef43d02dd8f |
comparison
equal
deleted
inserted
replaced
33026:4b7b89b356e8 | 33027:669898c9a6c3 |
---|---|
3389 endclass | 3389 endclass |
3390 END | 3390 END |
3391 v9.CheckScriptFailure(lines, 'E1349: Function "_Foo" of interface "Intf" not implemented') | 3391 v9.CheckScriptFailure(lines, 'E1349: Function "_Foo" of interface "Intf" not implemented') |
3392 enddef | 3392 enddef |
3393 | 3393 |
3394 " Test for using the return value of a class/object method as a function | |
3395 " argument. | |
3396 def Test_objmethod_funcarg() | |
3397 var lines =<< trim END | |
3398 vim9script | |
3399 | |
3400 class C | |
3401 def Foo(): string | |
3402 return 'foo' | |
3403 enddef | |
3404 endclass | |
3405 | |
3406 def Bar(a: number, s: string): string | |
3407 return s | |
3408 enddef | |
3409 | |
3410 def Baz(c: C) | |
3411 assert_equal('foo', Bar(10, c.Foo())) | |
3412 enddef | |
3413 | |
3414 var t = C.new() | |
3415 Baz(t) | |
3416 END | |
3417 v9.CheckScriptSuccess(lines) | |
3418 | |
3419 lines =<< trim END | |
3420 vim9script | |
3421 | |
3422 class C | |
3423 static def Foo(): string | |
3424 return 'foo' | |
3425 enddef | |
3426 endclass | |
3427 | |
3428 def Bar(a: number, s: string): string | |
3429 return s | |
3430 enddef | |
3431 | |
3432 def Baz() | |
3433 assert_equal('foo', Bar(10, C.Foo())) | |
3434 enddef | |
3435 | |
3436 Baz() | |
3437 END | |
3438 v9.CheckScriptSuccess(lines) | |
3439 enddef | |
3440 | |
3394 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 3441 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |