From 12fdb58da60976e2f7dfe9f37f46113ec94e2d8a Mon Sep 17 00:00:00 2001 From: Christian Buttner Date: Mon, 1 Jul 2024 13:16:39 +0200 Subject: [PATCH] Implicitly cast distinct inline to index. (#1218) Implicitly cast distinct inline to index. --- src/compiler/sema_casts.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index ef9e0a4c4..ac2e89b4b 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -588,8 +588,9 @@ static void expr_recursively_rewrite_untyped_list(Expr *expr, Expr **list) bool cast_to_index(SemaContext *context, Expr *index) { - Type *type = index->type->canonical; + Type *type = index->type; RETRY: + type = type_flat_distinct_inline(type); switch (type->type_kind) { case TYPE_I8: @@ -609,7 +610,7 @@ bool cast_to_index(SemaContext *context, Expr *index) SEMA_ERROR(index, "index->type->canonical this to an int or long."); return false; case TYPE_ENUM: - type = type->decl->enums.type_info->type->canonical; + type = type->decl->enums.type_info->type; goto RETRY; default: SEMA_ERROR(index, "Cannot implicitly convert '%s' to an index.", type_to_error_string(index->type));