From 20964b43ceb6979aece0ee9a92cde02b19e85c3e Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 2 Jul 2025 12:01:52 +0200 Subject: [PATCH] Fix of const enum resolution order #2264 --- src/compiler/sema_types.c | 2 +- .../enum_const_resolution_order.c3t | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/test_suite/enumerations/enum_const_resolution_order.c3t diff --git a/src/compiler/sema_types.c b/src/compiler/sema_types.c index da230392a..fd8116206 100644 --- a/src/compiler/sema_types.c +++ b/src/compiler/sema_types.c @@ -226,7 +226,6 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in case DECL_BITSTRUCT: case DECL_UNION: case DECL_ENUM: - case DECL_CONST_ENUM: case DECL_INTERFACE: type_info->type = decl->type; type_info->resolve_status = RESOLVE_DONE; @@ -236,6 +235,7 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in type_info->type = decl->type; type_info->resolve_status = RESOLVE_DONE; return true; + case DECL_CONST_ENUM: case DECL_DISTINCT: if (resolve_type_kind & RESOLVE_TYPE_NO_CHECK_DISTINCT) { diff --git a/test/test_suite/enumerations/enum_const_resolution_order.c3t b/test/test_suite/enumerations/enum_const_resolution_order.c3t new file mode 100644 index 000000000..f7f137428 --- /dev/null +++ b/test/test_suite/enumerations/enum_const_resolution_order.c3t @@ -0,0 +1,18 @@ +module foo; +import bar; + +struct Foo +{ + MyEnum value; +} + +module bar; + +enum MyEnum : const CInt +{ + VAL1 = 1, + VAL2 = 2, + VAL3 = 3, +} + +fn void main() {}