authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-05 19:20:31-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-05 19:20:31-05:00
log28403eaad0c4da28ff31152edbe2af659b2af500
tree5463479bfe991472387028bd6f7b9271c3190bcd
parent837cc467f7796bd098acce64f77b82060f4921e4

pass more tests by updating expected error messages


2 files changed, 7 insertions(+), 6 deletions(-)

src/analyze.cpp+3-2
...@@ -1108,7 +1108,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1108,7 +1108,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1108 if (enum_type->data.enumeration.embedded_in_current) {1108 if (enum_type->data.enumeration.embedded_in_current) {
1109 if (!enum_type->data.enumeration.reported_infinite_err) {1109 if (!enum_type->data.enumeration.reported_infinite_err) {
1110 enum_type->data.enumeration.reported_infinite_err = true;1110 enum_type->data.enumeration.reported_infinite_err = true;
1111 add_node_error(g, decl_node, buf_sprintf("enum contains itself"));1111 add_node_error(g, decl_node, buf_sprintf("enum '%s' contains itself", buf_ptr(&enum_type->name)));
1112 }1112 }
1113 return;1113 return;
1114 }1114 }
...@@ -1286,7 +1286,8 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1286,7 +1286,8 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1286 struct_type->data.structure.is_invalid = true;1286 struct_type->data.structure.is_invalid = true;
1287 if (!struct_type->data.structure.reported_infinite_err) {1287 if (!struct_type->data.structure.reported_infinite_err) {
1288 struct_type->data.structure.reported_infinite_err = true;1288 struct_type->data.structure.reported_infinite_err = true;
1289 add_node_error(g, decl_node, buf_sprintf("struct contains itself"));1289 add_node_error(g, decl_node,
1290 buf_sprintf("struct '%s' contains itself", buf_ptr(&struct_type->name)));
1290 }1291 }
1291 return;1292 return;
1292 }1293 }
test/run_tests.cpp+4-4
...@@ -841,7 +841,7 @@ const x : i32 = 99;...@@ -841,7 +841,7 @@ const x : i32 = 99;
841fn f() {841fn f() {
842 x = 1;842 x = 1;
843}843}
844 )SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant");844 )SOURCE", 1, ".tmp_source.zig:4:7: error: cannot assign to constant");
845845
846846
847 add_compile_fail_case("missing else clause", R"SOURCE(847 add_compile_fail_case("missing else clause", R"SOURCE(
...@@ -849,18 +849,18 @@ fn f(b: bool) {...@@ -849,18 +849,18 @@ fn f(b: bool) {
849 const x : i32 = if (b) { 1 };849 const x : i32 = if (b) { 1 };
850 const y = if (b) { i32(1) };850 const y = if (b) { i32(1) };
851}851}
852 )SOURCE", 2, ".tmp_source.zig:3:21: error: expected type 'i32', found 'void'",852 )SOURCE", 2, ".tmp_source.zig:3:30: error: integer value 1 cannot be implicitly casted to type 'void'",
853 ".tmp_source.zig:4:15: error: incompatible types: 'i32' and 'void'");853 ".tmp_source.zig:4:15: error: incompatible types: 'i32' and 'void'");
854854
855 add_compile_fail_case("direct struct loop", R"SOURCE(855 add_compile_fail_case("direct struct loop", R"SOURCE(
856const A = struct { a : A, };856const A = struct { a : A, };
857 )SOURCE", 1, ".tmp_source.zig:2:1: error: 'A' depends on itself");857 )SOURCE", 1, ".tmp_source.zig:2:11: error: struct 'A' contains itself");
858858
859 add_compile_fail_case("indirect struct loop", R"SOURCE(859 add_compile_fail_case("indirect struct loop", R"SOURCE(
860const A = struct { b : B, };860const A = struct { b : B, };
861const B = struct { c : C, };861const B = struct { c : C, };
862const C = struct { a : A, };862const C = struct { a : A, };
863 )SOURCE", 1, ".tmp_source.zig:2:1: error: 'A' depends on itself");863 )SOURCE", 1, ".tmp_source.zig:2:11: error: struct 'A' contains itself");
864864
865 add_compile_fail_case("invalid struct field", R"SOURCE(865 add_compile_fail_case("invalid struct field", R"SOURCE(
866const A = struct { x : i32, };866const A = struct { x : i32, };