patch 8.2.1272: Vim9: type not checked if declaration also assigns value
Problem: Vim9: type not checked if declaration also assigns value.
Solution: Check the type. (issue #6507)
diff --git a/src/eval.c b/src/eval.c
index c3f0ee5..a8e388d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1270,7 +1270,12 @@
}
}
else
+ {
+ if (lp->ll_type != NULL
+ && check_typval_type(lp->ll_type, rettv) == FAIL)
+ return;
set_var_const(lp->ll_name, lp->ll_type, rettv, copy, flags);
+ }
*endp = cc;
}
else if (var_check_lock(lp->ll_newkey == NULL