From a5ff983266f0a5e0717fcffb0cd1d3449b68b3a7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 4 May 2019 13:11:56 +0100 Subject: Fix parapoly related bugs #370 --- src/check_expr.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src/check_expr.cpp') 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; + } + } } } -- cgit v1.2.3