From c4c6975f1b36eb4848aacf81c7be3584c51f9ab6 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Tue, 11 Jul 2017 14:40:27 +0100 Subject: `cast(Type)expr`; Fix overloaded procedure determination on assignment --- src/check_decl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 1ce518318..52f785ef6 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -23,13 +23,27 @@ Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String contex } + if (operand->mode == Addressing_Overload) { + if (e->type == nullptr) { + error(operand->expr, "Cannot determine type from overloaded procedure `%.*s`", LIT(operand->overload_entities[0]->token.string)); + } else { + check_assignment(c, operand, e->type, str_lit("variable assignment")); + if (operand->mode != Addressing_Type) { + return operand->type; + } + } + } + if (e->type == nullptr) { e->type = t_invalid; } return nullptr; } + + if (e->type == nullptr) { + // NOTE(bill): Use the type of the operand Type *t = operand->type; if (is_type_untyped(t)) { -- cgit v1.2.3