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) {
11081108 if (enum_type->data.enumeration.embedded_in_current) {
11091109 if (!enum_type->data.enumeration.reported_infinite_err) {
11101110 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)));
11121112 }
11131113 return;
11141114 }
......@@ -1286,7 +1286,8 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
12861286 struct_type->data.structure.is_invalid = true;
12871287 if (!struct_type->data.structure.reported_infinite_err) {
12881288 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)));
12901291 }
12911292 return;
12921293 }
test/run_tests.cpp+4-4
......@@ -841,7 +841,7 @@ const x : i32 = 99;
841841fn f() {
842842 x = 1;
843843}
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
847847 add_compile_fail_case("missing else clause", R"SOURCE(
......@@ -849,18 +849,18 @@ fn f(b: bool) {
849849 const x : i32 = if (b) { 1 };
850850 const y = if (b) { i32(1) };
851851}
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'",
853853 ".tmp_source.zig:4:15: error: incompatible types: 'i32' and 'void'");
854854
855855 add_compile_fail_case("direct struct loop", R"SOURCE(
856856const 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
859859 add_compile_fail_case("indirect struct loop", R"SOURCE(
860860const A = struct { b : B, };
861861const B = struct { c : C, };
862862const 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
865865 add_compile_fail_case("invalid struct field", R"SOURCE(
866866const A = struct { x : i32, };