aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-05-04 13:11:56 +0100
committergingerBill <bill@gingerbill.org>2019-05-04 13:11:56 +0100
commita5ff983266f0a5e0717fcffb0cd1d3449b68b3a7 (patch)
tree33179e57466756c048610445103a6d328af2f36a /src
parenta46a1f5f34d281ecede1b446fea7be8834496da5 (diff)
Fix parapoly related bugs #370
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp33
-rw-r--r--src/check_type.cpp14
2 files changed, 37 insertions, 10 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 3ba270845..de409a54e 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -1429,7 +1429,6 @@ bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Typ
}
}
-
return false;
}
@@ -4352,12 +4351,14 @@ isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs
if (lhs != nullptr) {
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
Entity *e = lhs[tuple_index + j];
- DeclInfo *decl = decl_info_of_entity(e);
- if (decl != nullptr) {
- c->decl = decl; // will be reset by the 'defer' any way
- for_array(k, decl->deps.entries) {
- Entity *dep = decl->deps.entries[k].ptr;
- add_declaration_dependency(c, dep); // TODO(bill): Should this be here?
+ if (e != nullptr) {
+ DeclInfo *decl = decl_info_of_entity(e);
+ if (decl != nullptr) {
+ c->decl = decl; // will be reset by the 'defer' any way
+ for_array(k, decl->deps.entries) {
+ Entity *dep = decl->deps.entries[k].ptr;
+ add_declaration_dependency(c, dep); // TODO(bill): Should this be here?
+ }
}
}
}
@@ -4438,9 +4439,11 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count,
if (lhs != nullptr && tuple_index < lhs_count) {
// NOTE(bill): override DeclInfo for dependency
Entity *e = lhs[tuple_index];
- DeclInfo *decl = decl_info_of_entity(e);
- if (decl) c->decl = decl;
- type_hint = e->type;
+ if (e != nullptr) {
+ DeclInfo *decl = decl_info_of_entity(e);
+ if (decl) c->decl = decl;
+ type_hint = e->type;
+ }
}
check_expr_base(c, &o, rhs[i], type_hint);
@@ -4943,6 +4946,16 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
lhs = pt->params->Tuple.variables.data;
lhs_count = pt->params->Tuple.variables.count;
}
+ } else {
+ // NOTE(bill): Create 'lhs' list in order to ignore parameters which are polymorphic
+ lhs_count = pt->params->Tuple.variables.count;
+ lhs = gb_alloc_array(heap_allocator(), Entity *, lhs_count);
+ for_array(i, pt->params->Tuple.variables) {
+ Entity *e = pt->params->Tuple.variables[i];
+ if (!is_type_polymorphic(e->type)) {
+ lhs[i] = e;
+ }
+ }
}
}
diff --git a/src/check_type.cpp b/src/check_type.cpp
index f9f45361e..bd3271dcf 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1554,6 +1554,13 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
success = false;
type = t_invalid;
}
+ if (is_type_untyped(default_type(type))) {
+ gbString str = type_to_string(type);
+ error(o.expr, "Cannot determine type from the parameter, got '%s'", str);
+ gb_string_free(str);
+ success = false;
+ type = t_invalid;
+ }
bool modify_type = !ctx->no_polymorphic_errors;
if (specialization != nullptr && !check_type_specialization_to(ctx, specialization, type, false, modify_type)) {
@@ -1604,6 +1611,13 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
success = false;
}
}
+ if (is_type_untyped(default_type(type))) {
+ gbString str = type_to_string(type);
+ error(op.expr, "Cannot determine type from the parameter, got '%s'", str);
+ gb_string_free(str);
+ success = false;
+ type = t_invalid;
+ }
}
if (p->flags&FieldFlag_no_alias) {