Patch 9.0.1296
Problem: Calling an object method with arguments does not work. (Ernie
Rael)
Solution: Take the argument count into account when looking up the object.
(closes #11911)
Files: src/vim9execute.c, src/testdir/test_vim9_class.vim
*** ../vim-9.0.1295/src/vim9execute.c 2023-02-08 20:55:23.932100744 +0000
--- src/vim9execute.c 2023-02-10 15:45:08.369985067 +0000
***************
*** 4143,4150 ****
// call a method on an interface
case ISN_METHODCALL:
{
SOURCING_LNUM = iptr->isn_lnum;
! tv = STACK_TV_BOT(-1);
if (tv->v_type != VAR_OBJECT)
{
object_required_error(tv);
--- 4143,4152 ----
// call a method on an interface
case ISN_METHODCALL:
{
+ cmfunc_T *mfunc = iptr->isn_arg.mfunc;
+
SOURCING_LNUM = iptr->isn_lnum;
! tv = STACK_TV_BOT(-1 - mfunc->cmf_argcount);
if (tv->v_type != VAR_OBJECT)
{
object_required_error(tv);
***************
*** 4154,4160 ****
class_T *cl = obj->obj_class;
// convert the interface index to the object index
- cmfunc_T *mfunc = iptr->isn_arg.mfunc;
int idx = object_index_from_itf_index(mfunc->cmf_itf,
TRUE, mfunc->cmf_idx, cl);
--- 4156,4161 ----
*** ../vim-9.0.1295/src/testdir/test_vim9_class.vim 2023-02-08
20:55:23.936100739 +0000
--- src/testdir/test_vim9_class.vim 2023-02-10 15:49:06.750004642 +0000
***************
*** 1373,1378 ****
--- 1373,1419 ----
v9.CheckScriptSuccess(lines)
enddef
+ def Test_using_base_class()
+ var lines =<< trim END
+ vim9script
+
+ class BaseEE
+ def Enter(): any
+ return null
+ enddef
+ def Exit(resource: any): void
+ enddef
+ endclass
+
+ class ChildEE extends BaseEE
+ def Enter(): any
+ return 42
+ enddef
+
+ def Exit(resource: number): void
+ g:result ..= '/exit'
+ enddef
+ endclass
+
+ def With(ee: BaseEE)
+ var r = ee.Enter()
+ try
+ g:result ..= r
+ finally
+ g:result ..= '/finally'
+ ee.Exit(r)
+ endtry
+ enddef
+
+ g:result = ''
+ With(ChildEE.new())
+ assert_equal('42/finally/exit', g:result)
+ END
+ v9.CheckScriptSuccess(lines)
+ unlet g:result
+ enddef
+
+
def Test_class_import()
var lines =<< trim END
vim9script
*** ../vim-9.0.1295/src/version.c 2023-02-10 14:50:27.502918634 +0000
--- src/version.c 2023-02-10 15:46:15.721993837 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1296,
/**/
--
In a world without walls and borders, who needs windows and gates?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230210155255.17DC41C0396%40moolenaar.net.