Init new repository
This commit is contained in:
37
tests/field_access.txt
Normal file
37
tests/field_access.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
import "libc";
|
||||
|
||||
T :: struct {
|
||||
a: int;
|
||||
t2: T2;
|
||||
}
|
||||
|
||||
T2 :: struct {
|
||||
b: int;
|
||||
}
|
||||
|
||||
T3 :: struct {
|
||||
om: T;
|
||||
}
|
||||
|
||||
main :: proc(): int {
|
||||
t: T;
|
||||
a := t.a; @unused
|
||||
b := (t).a; @unused
|
||||
|
||||
i0 := :T{10}.a;
|
||||
i1 := :T{}.t2.b;
|
||||
i2 := :T{t2={1}}.t2;
|
||||
|
||||
assert(i0 == 10);
|
||||
assert(i1 == 0);
|
||||
assert(i2.b == 1);
|
||||
assert(t.t2.b == 0);
|
||||
|
||||
i3: T3;
|
||||
i3.om.a = 10;
|
||||
i3.om.t2.b = 10;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user