aboutsummaryrefslogtreecommitdiff
path: root/src/checker/stmt.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-10-22 19:41:58 +0100
committerGinger Bill <bill@gingerbill.org>2016-10-22 19:41:58 +0100
commitf60dc7b0a7f8bf8122df0fa3b4d12603a9775f87 (patch)
treeadd8d1125cf0bf5c40f0c6d39579705b2cb1bc98 /src/checker/stmt.cpp
parenta675d3f94d2c10ce6e50b88c6c39b36c746a4d2a (diff)
Minor Style Fixes
Diffstat (limited to 'src/checker/stmt.cpp')
-rw-r--r--src/checker/stmt.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/checker/stmt.cpp b/src/checker/stmt.cpp
index 0b703edac..027c072a0 100644
--- a/src/checker/stmt.cpp
+++ b/src/checker/stmt.cpp
@@ -983,7 +983,7 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
isize rhs_count = operands.count;
isize operand_index = 0;
- for_array(i, as->lhs) {
+ for_array(i, operands) {
AstNode *lhs = as->lhs[i];
check_assignment_variable(c, &operands[i], lhs);
}
@@ -1400,16 +1400,19 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
Token token = bs->token;
switch (token.kind) {
case Token_break:
- if ((flags & Stmt_BreakAllowed) == 0)
+ if ((flags & Stmt_BreakAllowed) == 0) {
error(token, "`break` only allowed in `for` or `match` statements");
+ }
break;
case Token_continue:
- if ((flags & Stmt_ContinueAllowed) == 0)
+ if ((flags & Stmt_ContinueAllowed) == 0) {
error(token, "`continue` only allowed in `for` statements");
+ }
break;
case Token_fallthrough:
- if ((flags & Stmt_FallthroughAllowed) == 0)
+ if ((flags & Stmt_FallthroughAllowed) == 0) {
error(token, "`fallthrough` statement in illegal position");
+ }
break;
default:
error(token, "Invalid AST: Branch Statement `%.*s`", LIT(token.string));
@@ -1432,7 +1435,6 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
e = scope_lookup_entity(c->context.scope, name);
} else if (expr->kind == AstNode_SelectorExpr) {
Operand o = {};
- check_expr_base(c, &o, expr->SelectorExpr.expr);
e = check_selector(c, &o, expr);
is_selector = true;
}
@@ -1499,15 +1501,6 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
}
} break;
- case Entity_Constant:
- error(us->token, "`using` cannot be applied to a constant");
- break;
-
- case Entity_Procedure:
- case Entity_Builtin:
- error(us->token, "`using` cannot be applied to a procedure");
- break;
-
case Entity_Variable: {
Type *t = base_type(type_deref(e->type));
if (is_type_struct(t) || is_type_raw_union(t)) {
@@ -1533,8 +1526,29 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
}
} break;
+ case Entity_Constant:
+ error(us->token, "`using` cannot be applied to a constant");
+ break;
+
+ case Entity_Procedure:
+ case Entity_Builtin:
+ error(us->token, "`using` cannot be applied to a procedure");
+ break;
+
+ case Entity_ImplicitValue:
+ error(us->token, "`using` cannot be applied to an implicit value");
+ break;
+
+ case Entity_Nil:
+ error(us->token, "`using` cannot be applied to `nil`");
+ break;
+
+ case Entity_Invalid:
+ error(us->token, "`using` cannot be applied to an invalid entity");
+ break;
+
default:
- GB_PANIC("TODO(bill): using other expressions?");
+ GB_PANIC("TODO(bill): `using` other expressions?");
}
case_end;