diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-04-16 22:30:48 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-04-16 22:30:48 +0100 |
| commit | 187b186112f88b883a6366f7cd1b4a1ef32d3232 (patch) | |
| tree | c10f1d8af8a0bdfa22941aac7bf67fa168a83f0b /src/check_stmt.c | |
| parent | 5041a35b95e4e911697b464d6f20f99aef7a598b (diff) | |
Add `#require_results` for procedures
Diffstat (limited to 'src/check_stmt.c')
| -rw-r--r-- | src/check_stmt.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/check_stmt.c b/src/check_stmt.c index c66729005..ca3bc9ac9 100644 --- a/src/check_stmt.c +++ b/src/check_stmt.c @@ -442,9 +442,11 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { Operand operand = {Addressing_Invalid}; ExprKind kind = check_expr_base(c, &operand, es->expr, NULL); switch (operand.mode) { - case Addressing_Type: - error_node(node, "Is not an expression"); - break; + case Addressing_Type: { + gbString str = type_to_string(operand.type); + error_node(node, "`%s` is not an expression", str); + gb_string_free(str); + } break; case Addressing_NoValue: return; default: { @@ -452,6 +454,15 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { return; } if (operand.expr->kind == AstNode_CallExpr) { + AstNodeCallExpr *ce = &operand.expr->CallExpr; + Type *t = type_of_expr(&c->info, ce->proc); + if (is_type_proc(t)) { + if (t->Proc.require_results) { + gbString expr_str = expr_to_string(ce->proc); + error_node(node, "`%s` requires that its results must be handled", expr_str); + gb_string_free(expr_str); + } + } return; } gbString expr_str = expr_to_string(operand.expr); |