patch 9.0.1250: cannot use an object method with :defer
Problem: Cannot use an object method with :defer. (Ernie Rael)
Solution: Find the object method and generate code to call it.
(closes #11886)
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 1034f64..06d1657 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -370,6 +370,17 @@
}
}
+ // Could be a function reference: "obj.Func".
+ for (int i = 0; i < cl->class_obj_method_count; ++i)
+ {
+ ufunc_T *fp = cl->class_obj_methods[i];
+ // Use a separate pointer to avoid that ASAN complains about
+ // uf_name[] only being 4 characters.
+ char_u *ufname = (char_u *)fp->uf_name;
+ if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL)
+ return generate_FUNCREF(cctx, fp, NULL);
+ }
+
semsg(_(e_member_not_found_on_object_str_str), cl->class_name, name);
}
else