aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-04-10 20:51:44 +0100
committergingerBill <bill@gingerbill.org>2018-04-10 20:51:44 +0100
commita83d916fadec8f18ed4baff0133defaff93795b2 (patch)
tree891c0f45194174dbe77c5c4b3897332484894f0a /src/check_expr.cpp
parente71a6413799577b2e422026003cfcd0fac72c7c7 (diff)
Fix immutable `context` to `any` assignment #214
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp12
1 files 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;