mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-13 03:27:44 -04:00
Casting a polymorphic procedure to `rawptr`, or to a procedure type it cannot be specialized to, was accepted. There is no procedure to take the address of, so the value came out nil, or the build hung, as with `x := rawptr(avl.init_cmp)`. Assigning one to `rawptr` already errors; make `cast` and `transmute` match. Casting to a procedure type that specializes it still works, as assignment does.
21 lines
660 B
Odin
21 lines
660 B
Odin
// A polymorphic procedure has no value until it is specialized. Casting or transmuting one
|
|
// was accepted and then hung the build or produced nil; each must be an error.
|
|
|
|
package test_issues
|
|
|
|
import "core:container/avl"
|
|
|
|
poly :: proc(a: $T) -> T { return a }
|
|
|
|
global := rawptr(avl.init_cmp) // error
|
|
|
|
main :: proc() {
|
|
a := rawptr(poly) // error
|
|
b := cast(proc(string, int))poly // error
|
|
c := transmute(rawptr)poly // error
|
|
|
|
// casting to a procedure type it can be specialized to still works
|
|
d := cast(proc(int) -> int)poly
|
|
_, _, _, _, _ = global, a, b, c, d
|
|
}
|