odin-lang / Odin

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

Maybe(string) != string causes compiler crash #2672

Open Tetralux opened 1 year ago

Tetralux commented 1 year ago

Reproduction:

package bug

main :: proc() {
    x: Maybe(string)

    // Both of these cause the same crash.
    if x != "" {}
    if x == "" {}
}

Output when run:

> odin run bug.odin -file
bug.main
lb_emit_conv: src -> dst
Not Identical Maybe($T=string) != string
Not Identical union {string} != string
Not Identical 28073bf7f40 != 7ff6083ecf98
Not Identical 28073bf7fc0 != 7ff6083ecf98
odin\src\llvm_backend_expr.cpp(2234): Panic: Invalid type conversion: 'Maybe($T=string)' to 'string' for procedure 'bug.main'
Feoramund commented 3 months ago

I can confirm this is still happening as of the latest commit.