aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-10-12 20:52:19 +0100
committerGinger Bill <bill@gingerbill.org>2017-10-12 20:52:19 +0100
commit26d3c54aff549e7138f2a9c1a3d8355ffc9b3186 (patch)
tree0d4bec339308214be8424bc392ba79c0f0aae949 /src/check_expr.cpp
parent349a62121c34ec190f080fd516416d5ce13c51f1 (diff)
Fix issue #119
This may need better error messages
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 30b6928ef..c4f953ff7 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -405,7 +405,7 @@ bool is_polymorphic_type_assignable(Checker *c, Type *poly, Type *source, bool c
i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) {
if (operand->mode == Addressing_Invalid ||
type == t_invalid) {
- return 0;
+ return -1;
}
if (operand->mode == Addressing_Builtin) {
@@ -1192,8 +1192,9 @@ bool check_representable_as_constant(Checker *c, ExactValue in_value, Type *type
}
type = core_type(type);
-
- if (is_type_boolean(type)) {
+ if (type == t_invalid) {
+ return false;
+ } else if (is_type_boolean(type)) {
return in_value.kind == ExactValue_Bool;
} else if (is_type_string(type)) {
return in_value.kind == ExactValue_String;
@@ -1485,8 +1486,17 @@ void check_comparison(Checker *c, Operand *x, Operand *y, TokenKind op) {
gb_string_free(type_string);
}
} else {
- gbString xt = type_to_string(x->type);
- gbString yt = type_to_string(y->type);
+ gbString xt, yt;
+ if (x->mode == Addressing_Overload) {
+ xt = gb_string_make(heap_allocator(), "overloaded procedure");
+ } else {
+ xt = type_to_string(x->type);
+ }
+ if (y->mode == Addressing_Overload) {
+ yt = gb_string_make(heap_allocator(), "overloaded procedure");
+ } else {
+ yt = type_to_string(y->type);
+ }
err_str = gb_string_make(c->tmp_allocator,
gb_bprintf("mismatched types `%s` and `%s`", xt, yt));
gb_string_free(yt);