You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Odin: dev-2024-05:856537f0c
OS: Windows 10 Professional (version: 22H2), build 19045.4291
CPU: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
RAM: 16311 MiB
Backend: LLVM 17.0.1
Expected Behavior
No compiler panic.
Current Behavior
Compiler crashes with: Panic: Invalid type conversion
Failure Information
In a reference switch for a union type, that takes a pointer to a union, the default case will not correctly recognize the type as a pointer when passing it as a parameter to a procedure.
Here is a small case to reproduce the bug:
package main
import"core:fmt"
Union :: union {
}
ptr_proc :: proc(ptr : ^Union) {
}
variable : ^Union
main :: proc() {
switch &ref in variable {
case:
fmt.println(typeid_of(type_of(ref))) // ^Unionptr_proc(ref)
}
}
Here is the error message:
main.main
lb_emit_conv: src -> dst
Not Identical Union != ^Union
Not Identical union {} != ^Union
Not Identical 24e9e7d5a50 != 24e9e7e0da0
Not Identical 24e9e7d5af0 != 24e9e7e0da0
src\llvm_backend_expr.cpp(2324): Panic: Invalid type conversion: 'Union' to '^Union' for procedure 'main.main'
The text was updated successfully, but these errors were encountered:
package err
import "core:testing"
import rl "vendor:raylib"
@test
t1 :: proc(t: ^testing.T) {
Unit :: struct {
target: union{ rl.Vector3 },
}
units := make_soa(#soa[dynamic]Unit, 5)
ptrs := make([dynamic]#soa^ #soa[]Unit, 5)
all := units[:]
for _, i in all {
ptrs[i] = &all[i]
}
for p, i in ptrs {
// This seems to be the problem
p.target = rl.Vector3{auto_cast i, auto_cast i, auto_cast i}
}
for u, i in units {
testing.expect_value(t, u.target, rl.Vector3{auto_cast i, auto_cast i, auto_cast i})
}
}
~/git/Odin/odin test err.odin -file
err.t1
lb_emit_conv: src -> dst
Not Identical [3]f32 != [^]union {[3]f32}
Not Identical [3]f32 != [^]union {[3]f32}
Not Identical 7fc0bba58280 != 7fc0a0a49720
Not Identical 7fc0bba58280 != 7fc0a0a49720
src/llvm_backend_expr.cpp(2324): Panic: Invalid type conversion: '[3]f32' to '[^]union {[3]f32}' for procedure 'err.t1'
[1] 7329 illegal hardware instruction (core dumped) ~/git/Odin/odin test invalid_type_conversion.odin -file
Context
Odin: dev-2024-05:856537f0c
OS: Windows 10 Professional (version: 22H2), build 19045.4291
CPU: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
RAM: 16311 MiB
Backend: LLVM 17.0.1
Expected Behavior
No compiler panic.
Current Behavior
Compiler crashes with:
Panic: Invalid type conversion
Failure Information
In a reference switch for a union type, that takes a pointer to a union, the default case will not correctly recognize the type as a pointer when passing it as a parameter to a procedure.
Here is a small case to reproduce the bug:
Here is the error message:
The text was updated successfully, but these errors were encountered: