diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-13 11:35:01 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-13 11:35:01 +0100 |
| commit | 03570275c1cfd14014d81bcdf085c320c1902c40 (patch) | |
| tree | 3e23c41050d6fd61044b4cad5a80f03a833fb738 /src | |
| parent | b5587f1937edf8440fdf713988c9e3bc38886e93 (diff) | |
Fix issue #78 and have a better error message.
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index ba182db3f..c19fc9afb 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -6980,7 +6980,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t if (!ok) { gbString expr_str = expr_to_string(o->expr); gbString dst_type_str = type_to_string(t); - error(o->expr, "Cannot type assert `%s` to `%s`", expr_str, dst_type_str); + error(o->expr, "Cannot type assert `%s` to `%s` as it is not a variant of that union", expr_str, dst_type_str); gb_string_free(dst_type_str); gb_string_free(expr_str); o->mode = Addressing_Invalid; @@ -7000,7 +7000,9 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t add_type_info_type(c, o->type); add_type_info_type(c, t); } else { - error(o->expr, "Type assertions can only operate on unions and `any`"); + gbString str = type_to_string(o->type); + error(o->expr, "Type assertions can only operate on unions and `any`, got %s", str); + gb_string_free(str); o->mode = Addressing_Invalid; o->expr = node; return kind; |