diff options
| author | gingerBill <bill@gingerbill.org> | 2019-10-31 22:39:12 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-10-31 22:39:12 +0000 |
| commit | 560bdc339b1137ab6f52878a13dce0a4742b6153 (patch) | |
| tree | 0178ef62bc54f5120ce3d1a71bd4c86ebe0555cd | |
| parent | 01dfb1dac8b71b2b84bb585395063c52779f5674 (diff) | |
Fix stack overflow bug caused by polymorphic record with polymorphic constant parameters. #447
DOES NOT FIX THE UNDERLYING BUG
| -rw-r--r-- | src/check_expr.cpp | 8 | ||||
| -rw-r--r-- | src/check_type.cpp | 18 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 8612167c9..254a7ce51 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -6343,9 +6343,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper operand->type = found_entity->type; return err; } - if (failure) { - return CallArgumentError_NoneConstantParameter; - } + + String generated_name = make_string_c(expr_to_string(call)); @@ -6458,7 +6457,8 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Type *t Ast *s = ident->SelectorExpr.selector; ident = s; } - Type *ot = operand->type; GB_ASSERT(ot->kind == Type_Named); + Type *ot = operand->type; + GB_ASSERT(ot->kind == Type_Named); Entity *e = ot->Named.type_name; add_entity_use(c, ident, e); add_type_and_value(&c->checker->info, call, Addressing_Type, ot, empty_exact_value); diff --git a/src/check_type.cpp b/src/check_type.cpp index ef68203ab..cf5855a3e 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -262,25 +262,29 @@ Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type, for (isize j = 0; j < param_count; j++) { Entity *p = tuple->variables[j]; Operand o = ordered_operands[j]; + Entity *oe = entity_of_node(o.expr); + if (p == oe) { + // NOTE(bill): This is the same type, make sure that it will be be same thing and use that + // Saves on a lot of checking too below + continue; + } + if (p->kind == Entity_TypeName) { if (is_type_polymorphic(o.type)) { // NOTE(bill): Do not add polymorphic version to the gen_types skip = true; break; - } else if (!are_types_identical(o.type, p->type)) { - skip = true; - break; } - } else if (p->kind == Entity_Constant) { - if (o.mode != Addressing_Constant) { - if (failure) *failure = true; + if (!are_types_identical(o.type, p->type)) { skip = true; break; } + } else if (p->kind == Entity_Constant) { if (!compare_exact_values(Token_CmpEq, o.value, p->Constant.value)) { skip = true; break; - } else if (!are_types_identical(o.type, p->type)) { + } + if (!are_types_identical(o.type, p->type)) { skip = true; break; } |