odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.13k stars 551 forks source link

Compiler assertion for conversion from i32 to union{i32} #3713

Closed Tetralux closed 3 weeks ago

Tetralux commented 4 weeks ago

Windows x64, odin version dev-2024-06:68781f8dd.

package bug

main :: proc() {
    U :: union {i32}
    u := U(44)
}
bug.main
lb_emit_conv: src -> dst
Not Identical int != U
Not Identical int != union {i32}
Not Identical 7ff714df58c0 != 1d3846a86f0
Not Identical 7ff714df58c0 != 1d3846a87a0
odin\src\llvm_backend_expr.cpp(2328): Panic: Invalid type conversion: 'int' to 'U' for procedure 'bug.main'
Tetralux commented 4 weeks ago

If union {int} this works correctly, but any other integer type produces this bug.