patch 8.2.0519: Vim9: return type not properly checked
Problem: Vim9: return type not properly checked.
Solution: Check type properly, also at runtime.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 98936dd..0dfe5a1 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2432,7 +2432,7 @@
if (ret == FAIL && give_msg)
type_mismatch(expected, actual);
}
- return OK;
+ return ret;
}
/*
@@ -2444,7 +2444,7 @@
static int
need_type(type_T *actual, type_T *expected, int offset, cctx_T *cctx)
{
- if (check_type(expected, actual, FALSE))
+ if (check_type(expected, actual, FALSE) == OK)
return OK;
if (actual->tt_type != VAR_ANY && actual->tt_type != VAR_UNKNOWN)
{
@@ -4069,7 +4069,7 @@
lvar->lv_type = stacktype;
}
}
- else if (check_type(lvar->lv_type, stacktype, TRUE) == FAIL)
+ else if (need_type(stacktype, lvar->lv_type, -1, cctx) == FAIL)
goto theend;
}
else if (*p != '=' && check_type(type, stacktype, TRUE) == FAIL)