From a751177a3ec3e2fe1de6dfecaced80ae71a46e8c Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 31 Aug 2025 23:56:48 +0200 Subject: [PATCH] Const enum methods are not being recognized. #2445 --- releasenotes.md | 1 + src/compiler/compiler_internal.h | 1 + .../enumerations/const_enum_methods.c3t | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/test_suite/enumerations/const_enum_methods.c3t diff --git a/releasenotes.md b/releasenotes.md index a55139929..2fe821ac3 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -92,6 +92,7 @@ - Compiler module-scope pointer to slice with offset, causes assert. #2446 - Compiler hangs on == overload if other is generic #2443 - Fix missing end of line when encountering errors in project creation. +- Const enum methods are not being recognized. #2445 ### Stdlib changes - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 27690bf87..78da403e9 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -3221,6 +3221,7 @@ INLINE bool type_is_user_defined(Type *type) { static const bool user_defined_types[TYPE_LAST + 1] = { [TYPE_ENUM] = true, + [TYPE_CONST_ENUM] = true, [TYPE_STRUCT] = true, [TYPE_FUNC_RAW] = true, [TYPE_UNION] = true, diff --git a/test/test_suite/enumerations/const_enum_methods.c3t b/test/test_suite/enumerations/const_enum_methods.c3t new file mode 100644 index 000000000..8661304aa --- /dev/null +++ b/test/test_suite/enumerations/const_enum_methods.c3t @@ -0,0 +1,15 @@ +module test; + +enum Enum : const int +{ + E0, E1 +} + +fn void Enum.foo(self) {} + +fn int main() +{ + Enum e = E0; + e.foo(); + return 0; +} \ No newline at end of file