Skip to content

Commit 8520dc3

Browse files
committed
fixed: polyquery yield issue; polymorph with expression constraint
1 parent f5843db commit 8520dc3

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

compiler/src/checker.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5609,6 +5609,14 @@ CHECK_FUNC(polyquery, AstPolyQuery *query) {
56095609
return Check_Yield;
56105610

56115611
case TYPE_MATCH_YIELD:
5612+
if (context->cycle_detected) {
5613+
ONYX_ERROR(query->token->pos, Error_Critical, "Error solving for polymorphic variable '%b'.", param->poly_sym->token->text, param->poly_sym->token->length);
5614+
if (err_msg.text != NULL) onyx_submit_error(context, err_msg);
5615+
if (query->error_loc) ONYX_ERROR(query->error_loc->pos, Error_Critical, "Here is where the call is located."); // :ErrorMessage
5616+
}
5617+
5618+
return Check_Yield;
5619+
56125620
case TYPE_MATCH_FAILED: {
56135621
if (solved_something) continue;
56145622

compiler/src/clone.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,15 @@ AstNode* ast_clone(Context *context, void* n) {
594594
AstConstraint* dc = (AstConstraint *) nn;
595595
AstConstraint* sc = (AstConstraint *) node;
596596

597-
dc->args = NULL;
598-
bh_arr_new(context->gp_alloc, dc->args, bh_arr_length(sc->args));
599-
600-
bh_arr_each(AstTyped *, arg, sc->args) {
601-
bh_arr_push(dc->args, (AstTyped *) ast_clone(context, (AstNode *) *arg));
597+
if (sc->flags & Ast_Flag_Constraint_Is_Expression) {
598+
C(AstConstraint, const_expr);
599+
} else {
600+
dc->args = NULL;
601+
bh_arr_new(context->gp_alloc, dc->args, bh_arr_length(sc->args));
602+
603+
bh_arr_each(AstTyped *, arg, sc->args) {
604+
bh_arr_push(dc->args, (AstTyped *) ast_clone(context, (AstNode *) *arg));
605+
}
602606
}
603607

604608
dc->phase = Constraint_Phase_Waiting_To_Be_Queued;

0 commit comments

Comments
 (0)