0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.1.0673: Vim9: too recursive func calls when calling super-class method

Problem:  Vim9: too recursive func calls when calling super-class method
          with non-overriden super-call methods. (Aliaksei Budavei)
Solution: use interface method, when super is to be used (Ernie Rael)

When compiling "super.Func()" force class context to class that defines
function that is doing "super.Func()".
ISN_METHODCALL arg "cmf_is_super" for specific ufunc.

fixes: #15448
fixes: #15463 (2) super.method may not execute in context of defining
                  class
closes: #15477

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ernie Rael
2024-08-13 23:27:22 +02:00
committed by Christian Brabandt
parent d33afe12c6
commit 58c9579430
7 changed files with 171 additions and 15 deletions

View File

@@ -4400,14 +4400,23 @@ exec_instructions(ectx_T *ectx)
goto on_error;
}
class_T *cl = obj->obj_class;
ufunc_T *ufunc;
if (mfunc->cmf_is_super)
// Doing "super.Func", use the specific ufunc.
ufunc = mfunc->cmf_itf->class_obj_methods[
mfunc->cmf_idx];
else
{
class_T *cl = obj->obj_class;
// convert the interface index to the object index
int idx = object_index_from_itf_index(mfunc->cmf_itf,
TRUE, mfunc->cmf_idx, cl);
// convert the interface index to the object index
int idx = object_index_from_itf_index(mfunc->cmf_itf,
TRUE, mfunc->cmf_idx, cl);
ufunc = cl->class_obj_methods[idx];
}
if (call_ufunc(cl->class_obj_methods[idx], NULL,
mfunc->cmf_argcount, ectx, NULL, NULL) == FAIL)
if (call_ufunc(ufunc, NULL, mfunc->cmf_argcount, ectx,
NULL, NULL) == FAIL)
goto on_error;
}
break;