patch 9.0.1138: crash when expecting varargs but it is something else
Problem: Crash when expecting varargs but it is something else.
Solution: Only use the member when the type is a list. (closes #11774)
diff --git a/src/vim9instr.c b/src/vim9instr.c
index bd2c1b4..72ecbaa 100644
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -1841,7 +1841,13 @@
type_T *expected;
if (varargs && i >= type->tt_argcount - 1)
- expected = type->tt_args[type->tt_argcount - 1]->tt_member;
+ {
+ expected = type->tt_args[type->tt_argcount - 1];
+ if (expected != NULL && expected->tt_type == VAR_LIST)
+ expected = expected->tt_member;
+ if (expected == NULL)
+ expected = &t_any;
+ }
else if (i >= type->tt_min_argcount
&& actual->tt_type == VAR_SPECIAL)
expected = &t_any;