Added support for unions as a step towards lowering ADTs in the next pass to be written.
This commit is contained in:
3
tests/test_union.expected_results
Normal file
3
tests/test_union.expected_results
Normal file
@@ -0,0 +1,3 @@
|
||||
true
|
||||
4
|
||||
4.400000
|
||||
22
tests/test_union.krak
Normal file
22
tests/test_union.krak
Normal file
@@ -0,0 +1,22 @@
|
||||
import io:*
|
||||
|
||||
uni packed {
|
||||
var a: int
|
||||
var b: double
|
||||
}
|
||||
|
||||
obj loose {
|
||||
var a: int
|
||||
var b: double
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
var a: packed
|
||||
var b: loose
|
||||
println(#sizeof<packed> < #sizeof<loose>)
|
||||
a.a = 4
|
||||
println(a.a)
|
||||
a.b = 4.4
|
||||
println(a.b)
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user