Odin
Odin copied to clipboard
Type specialization oddities
The overview makes use of language like "In some cases, you may want to specify that a type must be a specialization of a certain type." but there are instances where the behavior doesn't seem to match this and appears inconsistent. After a brief discussion with gB, we decided to track this issue here.
For example, this compiles, despite believing that only structs of type A would be permitted.
A :: struct {
a: int
}
B:: struct {
b: int
}
ChildOfA :: struct {
using c: A
}
ListOfA :: struct($Item: typeid/A) {
items: []Item
}
list := ListOfA(B) {
items = []B{ B{ b = 1 }, B{ b = 2 } }
}
Furthermore, adding:
do_stuff :: proc($T: typeid/A, len: int) {
}
do_stuff(A, 12)
Results in "Cannot convert type A to the specialization A.
First reported by community member [GdR] obiwan87 on discord.