patch 9.0.1933: Can change the type of a v: variable using if_lua
Problem: Can change the type of a v: variable using if_lua.
Solution: Add additional handling of v: variables like :let.
closes: #13161
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/src/if_lua.c b/src/if_lua.c
index 2041f5b..65d265f 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -1900,6 +1900,16 @@
}
else
{
+ int type_error = FALSE;
+ if (dict == get_vimvar_dict()
+ && !before_set_vvar((char_u *)name, di, &tv, TRUE, &type_error))
+ {
+ clear_tv(&tv);
+ if (type_error)
+ return luaL_error(L,
+ "Setting v:%s to value with wrong type", name);
+ return 0;
+ }
// Clear the old value
clear_tv(&di->di_tv);
// Update the value