odin-lang/Odin

Struct containing a maybe of the same type leads to hung compilation

Opened this issue ยท 6 comments

Context

Whilst implementing something in a project I noticed that the below snippet of code would not generate a compilation error, but would instead leave the build in a hung state. The code itself (from my perspective) is nonsensical and I only discovered the issue when the build hung after mistakenly providing the same type to a struct field of type Maybe where the Maybe wraps the same type as the struct it's within.

package test

Test :: struct {
	t: Maybe(Test),
}

main :: proc() {}
Odin:    dev-2024-11:e6475fec4
OS:      Windows 11 Home Basic (version: 23H2), build 22631.4460
CPU:     12th Gen Intel(R) Core(TM) i7-12700KF
RAM:     32487 MiB
Backend: LLVM 18.1.8

Expected Behavior

Compilation failure similar to if you attempt to:

Error: Illegal declaration cycle of `Test`

Current Behavior

Compilation hangs and will not halt unless the user forces it to.

Might be related to #4498.

Possibly fixed in 9115c7a

I'll give this a test locally and confirm.

Seems like the issue is resolved, I now get a compiler error and the failing to halt issue is gone.

So it's not fixed because it's now a race condition. Which is "better"?

So it's not fixed because it's now a race condition. Which is "better"?

The hanging compile may ironically be better because it's consistent.