patch 8.2.3128: Vim9: uninitialzed list does not get type checked
Problem: Vim9: uninitialzed list does not get type checked.
Solution: Set the type when initializing the variable. (closes #8529)
diff --git a/src/vim9script.c b/src/vim9script.c
index 9dc67a7..8acb7c3 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -806,7 +806,7 @@
}
else
{
- sv = find_typval_in_script(&di->di_tv);
+ sv = find_typval_in_script(&di->di_tv, TRUE);
}
if (sv != NULL)
{
@@ -922,10 +922,11 @@
/*
* Find the script-local variable that links to "dest".
- * Returns NULL if not found.
+ * Returns NULL if not found and when "give_error" is TRUE this is considered
+ * an internal error.
*/
svar_T *
-find_typval_in_script(typval_T *dest)
+find_typval_in_script(typval_T *dest, int give_error)
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
int idx;
@@ -944,7 +945,8 @@
if (sv->sv_name != NULL && sv->sv_tv == dest)
return sv;
}
- iemsg("find_typval_in_script(): not found");
+ if (give_error)
+ iemsg("find_typval_in_script(): not found");
return NULL;
}
@@ -959,7 +961,7 @@
char_u *name,
where_T where)
{
- svar_T *sv = find_typval_in_script(dest);
+ svar_T *sv = find_typval_in_script(dest, TRUE);
int ret;
if (sv != NULL)