From d276d3767fd2d7a8a237d9e0b78ac93c11175cfc Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 28 Jan 2026 18:51:21 +0100 Subject: [PATCH] Incorrect handling when reporting fn with optional compile time type #2862 --- releasenotes.md | 1 + src/compiler/compiler_internal.h | 2 ++ test/test_suite/expressions/optional_untyped_list_return.c3 | 6 ++++++ 3 files changed, 9 insertions(+) create mode 100644 test/test_suite/expressions/optional_untyped_list_return.c3 diff --git a/releasenotes.md b/releasenotes.md index 940720c63..ea22e4593 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -140,6 +140,7 @@ - Crash when creating `$Type*` where `$Type` is an optional type #2848 - Crashes when using `io::EOF~!` in various unhandled places. #2848 - Crash when trying to create a const zero untyped list #2847 +- Incorrect handling when reporting fn with optional compile time type #2862 ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 8828ee8d9..17d437010 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -3095,6 +3095,8 @@ INLINE const char *type_invalid_storage_type_name(Type *type) return "a typeinfo"; case TYPE_WILDCARD: return "an empty value"; + case TYPE_OPTIONAL: + return "an optional with a compile time type"; default: UNREACHABLE; } diff --git a/test/test_suite/expressions/optional_untyped_list_return.c3 b/test/test_suite/expressions/optional_untyped_list_return.c3 new file mode 100644 index 000000000..8075ace7d --- /dev/null +++ b/test/test_suite/expressions/optional_untyped_list_return.c3 @@ -0,0 +1,6 @@ +fn $typeof({})? foo() {} // #error: A function may not return an optional with a compile time type, only macros may do + +fn int main() +{ + return 0; +} \ No newline at end of file