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

patch 9.0.1932: Vim9: error when using null object constructor

Problem:  Vim9: error when using null object constructor
Solution: Check for a null object only when calling an object method

closes: #13154
closes: #13163

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
Yegappan Lakshmanan
2023-09-24 23:09:10 +02:00
committed by Christian Brabandt
parent 960822a11f
commit 7398f367d5
3 changed files with 41 additions and 9 deletions

View File

@@ -535,15 +535,6 @@ call_dfunc(
// If this is an object method, the object is just before the arguments.
typval_T *obj = STACK_TV_BOT(0) - argcount - vararg_count - 1;
if (obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL
&& !IS_CONSTRUCTOR_METHOD(ufunc))
{
// If this is not the constructor method, then a valid object is
// needed.
emsg(_(e_using_null_object));
return FAIL;
}
// Check the argument types.
if (check_ufunc_arg_types(ufunc, argcount, vararg_count, ectx) == FAIL)
return FAIL;
@@ -610,6 +601,15 @@ call_dfunc(
// the first local variable.
if (IS_OBJECT_METHOD(ufunc))
{
if (obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL
&& !IS_CONSTRUCTOR_METHOD(ufunc))
{
// If this is not a constructor method, then a valid object is
// needed.
emsg(_(e_using_null_object));
return FAIL;
}
*STACK_TV_VAR(0) = *obj;
obj->v_type = VAR_UNKNOWN;
}