From a83d916fadec8f18ed4baff0133defaff93795b2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 10 Apr 2018 20:51:44 +0100 Subject: [PATCH] Fix immutable `context` to `any` assignment #214 --- src/check_expr.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index c2ca5471a..9168bdad8 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -565,9 +565,13 @@ i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) { if (is_type_any(dst)) { if (!is_type_polymorphic(src)) { - // NOTE(bill): Anything can cast to 'Any' - add_type_info_type(c, s); - return 10; + if (operand->mode == Addressing_Immutable && operand->type == t_context) { + return -1; + } else { + // NOTE(bill): Anything can cast to 'Any' + add_type_info_type(c, s); + return 10; + } } } @@ -5126,7 +5130,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t } init_preload(c); - o->mode = Addressing_Value; + o->mode = Addressing_Immutable; o->type = t_context; break;