Compound expression for union
This commit is contained in:
@@ -12,15 +12,9 @@ PushStruct :: (a: *MA.Arena, type: Type): *void
|
||||
result := MA.PushSize(a, ti.size->U64)
|
||||
return result
|
||||
|
||||
U :: union
|
||||
a: F64
|
||||
b: F32
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
arena: MA.Arena
|
||||
a: *int = PushStruct(&arena, int)
|
||||
Assert(arena.len == SizeOf(int))
|
||||
|
||||
memes: U
|
||||
|
||||
return 0
|
||||
32
examples/unions.core
Normal file
32
examples/unions.core
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
U :: union
|
||||
a: F64
|
||||
b: F32
|
||||
|
||||
C :: struct
|
||||
a: int
|
||||
b: int
|
||||
|
||||
Test :: struct
|
||||
a: 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}
|
||||
c2: C = {b = 10}
|
||||
|
||||
/* @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