patch 9.0.1140: cannot call an object method in a compiled function
Problem: Cannot call an object method in a compiled function.
Solution: Compile the instructins to invoke an object method.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 0bf04a1..1f26437 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -45,7 +45,7 @@
if (len == 4 && STRNCMP(name, "this", 4) == 0
&& cctx->ctx_ufunc != NULL
- && (cctx->ctx_ufunc->uf_flags & FC_OBJECT))
+ && (cctx->ctx_ufunc->uf_flags & (FC_OBJECT|FC_NEW)))
{
if (lvar != NULL)
{
@@ -313,7 +313,7 @@
|| arg_exists(name, len, NULL, NULL, NULL, cctx) == OK
|| (len == 4
&& cctx->ctx_ufunc != NULL
- && (cctx->ctx_ufunc->uf_flags & FC_OBJECT)
+ && (cctx->ctx_ufunc->uf_flags & (FC_OBJECT|FC_NEW))
&& STRNCMP(name, "this", 4) == 0)))
|| script_var_exists(name, len, cctx, NULL) == OK
|| class_member_index(name, len, NULL, cctx) >= 0
@@ -3018,7 +3018,7 @@
goto erret;
// For an object method and constructor "this" is the first local variable.
- if (ufunc->uf_flags & FC_OBJECT)
+ if (ufunc->uf_flags & (FC_OBJECT|FC_NEW))
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;