patch 9.0.1720: Vim9 class using wrong index for overridden method

5 views
Skip to first unread message

Christian Brabandt

unread,
Aug 16, 2023, 2:51:37 PM8/16/23
to vim...@googlegroups.com
patch 9.0.1720: Vim9 class using wrong index for overridden method

Commit: https://github.com/vim/vim/commit/a456b12011569be91418bbf6277d844c67e05e79
Author: Yegappan Lakshmanan <yega...@yahoo.com>
Date: Wed Aug 16 20:14:37 2023 +0200

patch 9.0.1720: Vim9 class using wrong index for overridden method

Problem: Vim9 class using wrong index for overridden method
Solution: Use correct index for overridden method

closes: #12524
closes: #12813

Signed-off-by: Christian Brabandt <c...@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yega...@yahoo.com>

diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index e566a9e64..e60b3b63c 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -1948,4 +1948,42 @@ def Test_call_method_in_extended_class()
v9.CheckScriptSuccess(lines)
enddef

+" Test for calling a method in the parent class that is extended partially.
+" This used to fail with the 'E118: Too many arguments for function: Text' error
+" message (Github issue #12524).
+def Test_call_method_in_parent_class()
+ var lines =<< trim END
+ vim9script
+
+ class Widget
+ this._lnum: number = 1
+
+ def SetY(lnum: number)
+ this._lnum = lnum
+ enddef
+
+ def Text(): string
+ return ''
+ enddef
+ endclass
+
+ class Foo extends Widget
+ def Text(): string
+ return '<Foo>'
+ enddef
+ endclass
+
+ def Stack(w1: Widget, w2: Widget): list<Widget>
+ w1.SetY(1)
+ w2.SetY(2)
+ return [w1, w2]
+ enddef
+
+ var foo1 = Foo.new()
+ var foo2 = Foo.new()
+ var l = Stack(foo1, foo2)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index bea47fefc..ae9bc87a2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1720,
/**/
1719,
/**/
diff --git a/src/vim9class.c b/src/vim9class.c
index 562db25b5..b04fb0fec 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -911,7 +911,7 @@ early_ret:
== 0)
{
int *table = (int *)(if2cl + 1);
- table[if_i] = cl_i;
+ table[if_i] = objmethods.ga_len + cl_i;
break;
}
}
Reply all
Reply to author
Forward
0 new messages