From d962cfdc6bd1865c7df302d08af237027533437f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 12 May 2021 22:38:37 +0100 Subject: Fix #713 --- src/check_expr.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index a64acf744..26c7983de 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5572,9 +5572,15 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } check_expr(c, operand, arg); if (operand->mode != Addressing_Invalid) { - check_cast(c, operand, t); + if (is_type_polymorphic(t)) { + error(call, "A polymorphic type cannot be used in a type conversion"); + } else { + // NOTE(bill): Otherwise the compiler can override the polymorphic type + // as it assumes it is determining the type + check_cast(c, operand, t); + } } - + operand->type = t; break; } } -- cgit v1.2.3