ability to return structs byvalue from functions

closes #57
This commit is contained in:
Andrew Kelley
2016-01-24 18:34:50 -07:00
parent ca7b85b32e
commit 419652ee8f
4 changed files with 193 additions and 73 deletions

View File

@@ -1233,6 +1233,27 @@ pub fn main(args: [][]u8) %void => {
print_str("OK\n");
return;
}
}
)SOURCE", "OK\n");
add_simple_case("return struct byval from function", R"SOURCE(
import "std.zig";
struct Foo {
x: i32,
y: i32,
}
fn make_foo() Foo => {
Foo {
.x = 1234,
.y = 5678,
}
}
pub fn main(args: [][]u8) %void => {
const foo = make_foo();
if (foo.y != 5678) {
print_str("BAD\n");
}
print_str("OK\n");
}
)SOURCE", "OK\n");
}