aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-04 23:14:55 +0100
committergingerBill <bill@gingerbill.org>2018-08-04 23:14:55 +0100
commitcdbf831a7a6d9bc36e3cf76d525c44af88dc0a53 (patch)
treeea6d0be0d032a77f6d7c0303be4dffd31c837412 /src/check_expr.cpp
parent0718f14774c152b84edb747c03ca53b9400407b9 (diff)
Replace `context <- c {}` with `context = c;`. context assignments are scope based
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 479103241..163d7f6d0 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -578,7 +578,7 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type
if (is_type_any(dst)) {
if (!is_type_polymorphic(src)) {
- if (operand->mode == Addressing_Immutable && operand->type == t_context) {
+ if (operand->mode == Addressing_Context && operand->type == t_context) {
return -1;
} else {
// NOTE(bill): Anything can cast to 'Any'
@@ -2040,6 +2040,17 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node) {
return;
}
+ if (x->mode == Addressing_Builtin) {
+ x->mode = Addressing_Invalid;
+ error(x->expr, "built-in expression in binary expression");
+ return;
+ }
+ if (y->mode == Addressing_Builtin) {
+ x->mode = Addressing_Invalid;
+ error(y->expr, "built-in expression in binary expression");
+ return;
+ }
+
if (token_is_shift(op.kind)) {
check_shift(c, x, y, node);
return;
@@ -2724,6 +2735,8 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ
// TODO(bill): Is this the rule I need?
if (operand->mode == Addressing_Immutable) {
// Okay
+ } else if (operand->mode == Addressing_Context) {
+ operand->mode = Addressing_Value; // TODO(bill): Should this be Value or Immutable?
} else if (sel.indirect || operand->mode != Addressing_Value) {
operand->mode = Addressing_Variable;
} else {
@@ -5211,7 +5224,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
}
init_core_context(c->checker);
- o->mode = Addressing_Immutable;
+ o->mode = Addressing_Context;
o->type = t_context;
break;