#Union Compiler Error When Passing Value Into Procedure

1 messages · Page 1 of 1 (latest)

lusty ferry
#

Foo_Bar :: struct {}
Foo_Baz_Buz :: struct {}

Foo_Baz :: union {
    Foo_Baz_Buz,
}

Foo :: union {
    Foo_Bar,
    Foo_Baz,
}

main :: proc() {
    func(Foo_Baz_Buz{}) // compiler error
    func(Foo(Foo_Baz(Foo_Baz_Buz{}))) // compiles
}

func :: proc(arg: Foo) {

}```

Error
```test/main.odin(16:7) Error: Cannot assign value 'Foo_Baz_Buz{}' of type 'Foo_Baz_Buz' to 'Foo' in a procedure argument
        func(Foo_Baz_Buz{})```

Is this a compiler bug or by design?
sweet bear
#

implicit casts only go one layer intentionally