Previously it wasnt working but now its working, TRUST ME
This commit is contained in:
40
build/examples/unions.core
Normal file
40
build/examples/unions.core
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
U :: union
|
||||
a: F64
|
||||
b: F32
|
||||
|
||||
C :: struct
|
||||
a: int
|
||||
b: int
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
memes: U
|
||||
memes.b = 10
|
||||
Assert(memes.b == 10)
|
||||
Assert(memes.a != 0)
|
||||
|
||||
compound: U = {b = 10.0}
|
||||
Assert(compound.b == 10)
|
||||
|
||||
t := U
|
||||
ti := GetTypeInfo(t)
|
||||
Assert(ti.size == SizeOf(U))
|
||||
|
||||
for ti.struct_members
|
||||
Assert(it.offset == 0)
|
||||
|
||||
ti_it := GetTypeInfo(it.type)
|
||||
Assert(ti_it.size != 0)
|
||||
|
||||
|
||||
/* @reproduction @todo
|
||||
```
|
||||
examples/unions.core - Error! Couldn't infer type of compound expression
|
||||
c = {10}
|
||||
```
|
||||
|
||||
c: C
|
||||
c = {10}
|
||||
*/
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user