patch 8.2.1011: Vim9: some code not tested
Problem: Vim9: some code not tested.
Solution: Add a few more test cases. Reorder checks for clearer error.
Remove unreachable code.
diff --git a/src/vim9script.c b/src/vim9script.c
index 442158c..6c4cbc4 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -507,7 +507,7 @@
/*
* Check if the type of script variable "dest" allows assigning "value".
*/
- void
+ int
check_script_var_type(typval_T *dest, typval_T *value, char_u *name)
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
@@ -521,13 +521,15 @@
if (sv->sv_tv == dest)
{
if (sv->sv_const)
+ {
semsg(_(e_readonlyvar), name);
- else
- check_type(sv->sv_type, typval2type(value), TRUE);
- return;
+ return FAIL;
+ }
+ return check_type(sv->sv_type, typval2type(value), TRUE);
}
}
iemsg("check_script_var_type(): not found");
+ return OK; // not really
}
#endif // FEAT_EVAL