From 5d15e601414604fb86510c2537d9fc6aab6e94e0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 12:45:36 +0300 Subject: [PATCH] cgen: Unhandled Exception when setting const to function that returns error or struct (fixes #23555) --- .../const_call_result_struct_dep_order_test.v | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 vlib/v/tests/consts/const_call_result_struct_dep_order_test.v diff --git a/vlib/v/tests/consts/const_call_result_struct_dep_order_test.v b/vlib/v/tests/consts/const_call_result_struct_dep_order_test.v new file mode 100644 index 000000000..c1df9bc15 --- /dev/null +++ b/vlib/v/tests/consts/const_call_result_struct_dep_order_test.v @@ -0,0 +1,21 @@ +enum Foo { + foo +} + +struct Something {} + +const something = new(.foo) or { panic(err.str()) } + +const bar = { + Foo.foo: 'some_string' +} + +fn new(foo Foo) !Something { + println(bar[foo]) + return Something{} +} + +fn test_const_call_result_struct_dep_order() { + assert something == Something{} + assert bar[.foo] == 'some_string' +} -- 2.39.5