]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0084: Vim9: isn_get_calltype() can be improved v9.2.0084
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 1 Mar 2026 17:02:52 +0000 (17:02 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 1 Mar 2026 17:02:52 +0000 (17:02 +0000)
Problem:  Vim9: isn_get_calltype() can be improved
Solution: Refactor isn_get_calltype for readability
          (Yegappan Lakshmanan).

related: #19519
closes:  #19529

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/version.c
src/vim9instr.c

index 7ede284b48da1bb3fef2f109a0d65d33e84153cc..1aeec3e40b895999512ff3f3f831279576184456 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    84,
 /**/
     83,
 /**/
index 90156bfa081b7fb65129798dc3abf20650002bd6..24834af673d65278246f5b4d96ae4d933b568cfd 100644 (file)
@@ -1910,8 +1910,11 @@ generate_BLOBAPPEND(cctx_T *cctx)
 }
 
 /*
- * get the instruction type for a function call: ISN_METHODCALL, ISN_DCALL, or
- * ISN_UCALL.
+ * Get the instruction type for a function call:
+ *   ISN_METHODCALL - object method call via interface
+ *   ISN_DCALL      - compiled def function call
+ *   ISN_UCALL      - uncompiled function, or
+ *                    compiled script-local function called from a lambda
  */
     static isntype_T
 isn_get_calltype(
@@ -1919,11 +1922,23 @@ isn_get_calltype(
        ufunc_T     *ufunc,
        class_T     *cl)
 {
-    return cl != NULL ? ISN_METHODCALL
-       : (ufunc->uf_def_status != UF_NOT_COMPILED
-               && ((cctx->ctx_ufunc->uf_flags & FC_LAMBDA) == 0
-                   || ufunc->uf_name[0] != K_SPECIAL))
-       ? ISN_DCALL : ISN_UCALL;
+    if (cl != NULL)
+       return ISN_METHODCALL;
+
+    if (ufunc->uf_def_status == UF_NOT_COMPILED)
+       return ISN_UCALL;
+
+    // function invoked from a lambda
+    if (cctx->ctx_ufunc->uf_flags & FC_LAMBDA)
+    {
+       // Script-local funcs in a lambda may be redefined by re-sourcing;
+       // resolve by name at runtime.  Patched to ISN_DCALL on next call once
+       // recompiled.
+       if (ufunc->uf_name[0] == K_SPECIAL)
+           return ISN_UCALL;
+    }
+
+    return ISN_DCALL;
 }
 
 /*