Open amjoshuamichael opened 3 days ago
I think I've found the approximate source of the problem.
check_value_decl_stmt (ctx=0x7fffe5c1f7e0, node=0x7fffc9795640, mod_flags=32)
at src/check_stmt.cpp:2086
2086 if (e->type == nullptr) {
(gdb) p init_type
$15 = (Type *) 0x0
(gdb) list
2082 }
2083 e->flags |= EntityFlag_Visited;
2084
2085 e->state = EntityState_InProgress;
2086 if (e->type == nullptr) {
2087 e->type = init_type;
2088 e->state = EntityState_Resolved;
2089 }
2090 ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix, ac.link_suffix);
2091
(gdb) p *e
$24 = {kind = Entity_Variable, id = 3021, flags = std::atomic<unsigned long> = { 1 },
state = std::atomic<EntityState> = { EntityState_InProgress }, token = {kind = Token_Ident,
flags = 0 '\000', string = {
text = 0x7fffc9793398 "list := make([dynamic]u8, cap = 2, allocator = context.allocator)\n return list[:];\n}\n", len = 4}, pos = {file_id = 28, offset = 104, line = 8,
column = 5}}, scope = 0x7fffcc7b9560, type = 0x0,
// More stuff below
init_type
is nullptr
here when it probably shouldn't for this local variable.
Context
Odin: dev-2024-10 OS: Arch Linux, Linux 6.11.3-arch1-1 CPU: Intel(R) Core(TM) i9-14900HX RAM: 15693 MiB Backend: LLVM 18.1.8
EDIT:
While doing some testing with this bug, which seems to only occur on linux, I've been able to replicate the bug on the following configuration:
Odin: dev-2024-10:af9ae4897 OS: macOS Sequoia 15 (build: 24A335, kernel: 24.0.0) CPU: Apple M2 Max RAM: 32768 MiB Backend: LLVM 18.1.8
[END OF EDIT]
Expected Behavior
Should throw an error complaining that I haven't specified the length of the dynamic array, like so:
This is the behavior when you don't return the dynamic array as a slice.
Current Behavior
Compiler segfaults.
Failure Information (for bugs)
Here's an lldb backtrace on my machine:
The error occurs here.
Steps to Reproduce
Here's a minimal program that produces the bug when I run
odin build .
on my machine.Failure Logs
Note: I've been loving Odin so far! Thank you to all the contributors for helping to build such a great language.