fix assignment operators for struct fields

This commit is contained in:
Andrew Kelley
2015-12-15 19:17:39 -07:00
parent 28c5a8f2ca
commit 5a8822c714
6 changed files with 135 additions and 66 deletions

View File

@@ -566,7 +566,7 @@ use "std.zig";
export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
var foo : Foo;
foo.a = foo.a + 1;
foo.a += 1;
foo.b = foo.a == 1;
test_foo(foo);
return 0;
@@ -749,7 +749,7 @@ fn f() {
const a = 3;
a = 4;
}
)SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant variable");
)SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant");
add_compile_fail_case("use of undeclared identifier", R"SOURCE(
fn f() {
@@ -787,7 +787,7 @@ const x : i32 = 99;
fn f() {
x = 1;
}
)SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant variable");
)SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant");
add_compile_fail_case("missing else clause", R"SOURCE(