mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1760: vim9 class problem with new() constructor
Problem: vim9 class problem with new() constructor Solution: Don't allow a return type for the new() class constructor. closes: #12863 closes: #12040 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
6cc8bc8366
commit
6ac1544e13
@@ -2617,8 +2617,16 @@ compile_return(char_u *arg, int check_return_type, int legacy, cctx_T *cctx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// No argument, return zero.
|
||||
generate_PUSHNR(cctx, 0);
|
||||
if (cctx->ctx_ufunc->uf_flags & FC_NEW)
|
||||
{
|
||||
// For a class new() constructor, return an object of the class.
|
||||
generate_instr(cctx, ISN_RETURN_OBJECT);
|
||||
cctx->ctx_ufunc->uf_ret_type =
|
||||
&cctx->ctx_ufunc->uf_class->class_object_type;
|
||||
}
|
||||
else
|
||||
// No argument, return zero.
|
||||
generate_PUSHNR(cctx, 0);
|
||||
}
|
||||
|
||||
// may need ENDLOOP when inside a :for or :while loop
|
||||
|
Reference in New Issue
Block a user