patch 8.2.1329: Vim9: cannot define global function inside :def function
Problem: Vim9: cannot define global function inside :def function.
Solution: Assign to global variable instead of local. (closes #6584)
diff --git a/src/vim9.h b/src/vim9.h
index 0d51c98..77f3427 100644
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -79,6 +79,7 @@
ISN_PCALL_END, // cleanup after ISN_PCALL with cpf_top set
ISN_RETURN, // return, result is on top of stack
ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref
+ ISN_NEWFUNC, // create a global function from a lambda function
// expression operations
ISN_JUMP, // jump if condition is matched isn_arg.jump
@@ -237,6 +238,12 @@
int fr_var_idx; // variable to store partial
} funcref_T;
+// arguments to ISN_NEWFUNC
+typedef struct {
+ char_u *nf_lambda; // name of the lambda already defined
+ char_u *nf_global; // name of the global function to be created
+} newfunc_T;
+
// arguments to ISN_CHECKLEN
typedef struct {
int cl_min_len; // minimum length
@@ -281,6 +288,7 @@
script_T script;
unlet_T unlet;
funcref_T funcref;
+ newfunc_T newfunc;
checklen_T checklen;
shuffle_T shuffle;
} isn_arg;