这是indexloc提供的服务,不要输入任何密码
Skip to content

Compiler hang with recursive union type #5487

@JackMordaunt

Description

@JackMordaunt

Context

A recursive union type definition causes the compiler to hang indefinitely.

Odin:    dev-2025-07:b095dd71c
OS:      macOS Sequoia 15.5.0 (build 24F74, kernel 24.5.0)
CPU:     Apple M1 Pro
RAM:     16384 MiB
Backend: LLVM 20.1.6

Expected Behavior

odin build . reports an error if it cannot compile the program.

Current Behavior

odin build . hangs.

Steps to Reproduce

This reproducer program hangs the compiler.
If you make the Vertex use an array of pointers, the compilation succeeds.
If you delete the Entity_Tree symbol (e.g. never give the Tree a type) compilation succeeds.

package main

Entity :: struct {
	x, y: int,
}

Entity_Tree :: Tree(^Entity) // Delete this type instantiation and the compilation works.

Tree :: struct($T: typeid) {
	root: Node(T),
}

// A recursive union definition hangs the build.
Node :: union($T: typeid) {
	Vertex(T),
	Leaf(T),
}

Vertex :: struct($T: typeid) {
	parts: [4]Node(T), // Make this an array of pointers, and compilation works.
}

Leaf :: struct($T: typeid) {
	value: T,
}


main :: proc() {

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions