Shared Generic across structs sometimes causes build errors
Context
Odin: dev-2023-11:dd9b0ae4
OS: Windows 10 Home Basic (version: 22H2), build 19045.3570
CPU: AMD Ryzen 5 3600 6-Core Processor
RAM: 16310 MiB
Expected Behavior
Allow to use Generic $T normally across structs in different procedures.
Current Behavior
crashes about 20% of the builds, otherwhise it compiles as expected. Maybe it's something about the build step and how structs get built internally with generics across threads?
Steps to Reproduce
package src
A :: struct($T: typeid) {
value: T,
}
B :: struct($T: typeid) {
a: A(T)
}
// second proc is important!
test :: proc() {
a: A(int) = { 10 }
b: B(int) = { a }
}
main :: proc() {
a: A(int) = { 10 }
b: B(int) = { a }
}
Failure Logs
.../main.odin(20:16) Cannot assign value 'a' of type 'A($T=int) (package src)' to 'A($T=int) (package src)' in structure literal
b: B(int) = { a }
^
Suggestion: the expression may be directly casted to type A($T=int)
or
.../main.odin(13:16) Too many values in structure literal, expected 0, got 1
b: B(int) = { a }
I ran the compiler with -fsanitize=thread using your example and race hazards were detected and reported. The reports are pretty easy to comprehend, but I don't know enough about the compiler internals to suggest fixes. I suspect a few well placed semaphores will go a long way!
The linked issue has been fixed, can you verify it also fixed this one?
Still happens, but the error rate isn't as frequent as before.
Can this be replicated any more on the latest commit?