patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Problem: Vim9: after reloading a script variable index may be invalid.
Solution: When the sequence number doesn't match give an error for using a
script-local variable from a compiled function. (closes #7547)
diff --git a/src/vim9.h b/src/vim9.h
index 9048d23..2752aa8 100644
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -244,8 +244,13 @@
// arguments to ISN_LOADSCRIPT and ISN_STORESCRIPT
typedef struct {
- int script_sid; // script ID
- int script_idx; // index in sn_var_vals
+ int sref_sid; // script ID
+ int sref_idx; // index in sn_var_vals
+ int sref_seq; // sn_script_seq when compiled
+} scriptref_T;
+
+typedef struct {
+ scriptref_T *scriptref;
} script_T;
// arguments to ISN_UNLET
@@ -345,6 +350,8 @@
int df_idx; // index in def_functions
int df_deleted; // if TRUE function was deleted
char_u *df_name; // name used for error messages
+ int df_script_seq; // Value of sctx_T sc_seq when the function
+ // was compiled.
garray_T df_def_args_isn; // default argument instructions
isn_T *df_instr; // function body to be executed