diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-17 15:08:36 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-17 15:08:36 +0100 |
| commit | 9a8759efefa24f5ae1e6d91b67dca72357a99ff9 (patch) | |
| tree | f0c5087618010a4fa4d85cbe019426f9c18a7ede /src/check_stmt.cpp | |
| parent | 054948e701c1340e72ac236d58da15ca9e6d617c (diff) | |
Polymorphic type specialization for procedures
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 51e6adf79..5df8694b1 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1608,16 +1608,21 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { Entity *e = nullptr; bool is_selector = false; - if (expr->kind == AstNode_Ident) { - Operand o = {}; + Operand o = {}; + switch (expr->kind) { + case AstNode_Ident: e = check_ident(c, &o, expr, nullptr, nullptr, true); - } else if (expr->kind == AstNode_SelectorExpr) { - Operand o = {}; + break; + case AstNode_SelectorExpr: e = check_selector(c, &o, expr, nullptr); is_selector = true; - } else if (expr->kind == AstNode_Implicit) { + break; + case AstNode_Implicit: error(us->token, "`using` applied to an implicit value"); continue; + default: + error(us->token, "`using` can only be applied to an entity, got %.*s", LIT(ast_node_strings[expr->kind])); + continue; } if (!check_using_stmt_entity(c, us, expr, is_selector, e)) { @@ -1722,7 +1727,9 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { if (init_type == nullptr) { init_type = t_invalid; } else if (is_type_polymorphic(base_type(init_type))) { - error(vd->type, "Invalid use of a polymorphic type in variable declaration"); + gbString str = type_to_string(init_type); + error(vd->type, "Invalid use of a polymorphic type `%s` in variable declaration", str); + gb_string_free(str); init_type = t_invalid; } } |