patch 9.2.0084: Vim9: isn_get_calltype() can be improved
Commit:
https://github.com/vim/vim/commit/689083a7481333036d4424bcc4c0f7864acf8fa5
Author: Yegappan Lakshmanan <[email protected]>
Date: Sun Mar 1 17:02:52 2026 +0000
patch 9.2.0084: Vim9: isn_get_calltype() can be improved
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 <[email protected]>
Signed-off-by: Yegappan Lakshmanan <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/version.c b/src/version.c
index 7ede284b4..1aeec3e40 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 84,
/**/
83,
/**/
diff --git a/src/vim9instr.c b/src/vim9instr.c
index 90156bfa0..24834af67 100644
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -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;
}
/*
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vwkNj-001gbY-9M%40256bit.org.