summaryrefslogtreecommitdiffstats
path: root/src/vim9type.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-01-16 16:39:37 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-16 16:39:37 +0000
commit450c7a97d1a28f715acaf562298112b9b932adc3 (patch)
treeb114bd1b76bde7f8e3dfefd427c137a518558292 /src/vim9type.c
parent5a57a5e209bff2bc11bfde69184bbfb0362c0b99 (diff)
patch 9.0.1207: error when object type is expected but getting "any"v9.0.1207
Problem: Error when object type is expected but getting "any". Solution: When actual type is "any" use a runtime type check. (closes #11826)
Diffstat (limited to 'src/vim9type.c')
-rw-r--r--src/vim9type.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vim9type.c b/src/vim9type.c
index fb32a8628f..08dabd1c22 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -878,6 +878,11 @@ check_type_maybe(
}
else if (expected->tt_type == VAR_OBJECT)
{
+ if (actual->tt_type == VAR_ANY)
+ return MAYBE; // use runtime type check
+ if (actual->tt_type != VAR_OBJECT)
+ return FAIL; // don't use tt_member
+
// check the class, base class or an implemented interface matches
class_T *cl;
for (cl = (class_T *)actual->tt_member; cl != NULL;