| ... | @@ -1022,16 +1022,15 @@ const x = foo(); | ... | @@ -1022,16 +1022,15 @@ const x = foo(); |
| 1022 | )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression"); | 1022 | )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression"); |
| 1023 | | 1023 | |
| 1024 | add_compile_fail_case("array concatenation with wrong type", R"SOURCE( | 1024 | add_compile_fail_case("array concatenation with wrong type", R"SOURCE( |
| 1025 | fn f(s: []u8) -> []u8 { | 1025 | const src = "aoeu"; |
| 1026 | s ++ "foo" | 1026 | const a = src[0...] ++ "foo"; |
| 1027 | } | 1027 | )SOURCE", 1, ".tmp_source.zig:3:14: error: expected array or C string literal, found '[]u8'"); |
| 1028 | )SOURCE", 1, ".tmp_source.zig:3:5: error: expected array or C string literal, found '[]u8'"); | | |
| 1029 | | 1028 | |
| 1030 | add_compile_fail_case("non compile time array concatenation", R"SOURCE( | 1029 | add_compile_fail_case("non compile time array concatenation", R"SOURCE( |
| 1031 | fn f(s: [10]u8) -> []u8 { | 1030 | fn f(s: [10]u8) -> []u8 { |
| 1032 | s ++ "foo" | 1031 | s ++ "foo" |
| 1033 | } | 1032 | } |
| 1034 | )SOURCE", 1, ".tmp_source.zig:3:5: error: array concatenation requires constant expression"); | 1033 | )SOURCE", 1, ".tmp_source.zig:3:5: error: unable to evaluate constant expression"); |
| 1035 | | 1034 | |
| 1036 | add_compile_fail_case("@cImport with bogus include", R"SOURCE( | 1035 | add_compile_fail_case("@cImport with bogus include", R"SOURCE( |
| 1037 | const c = @cImport(@cInclude("bogus.h")); | 1036 | const c = @cImport(@cInclude("bogus.h")); |
| ... | @@ -1041,14 +1040,8 @@ const c = @cImport(@cInclude("bogus.h")); | ... | @@ -1041,14 +1040,8 @@ const c = @cImport(@cInclude("bogus.h")); |
| 1041 | add_compile_fail_case("address of number literal", R"SOURCE( | 1040 | add_compile_fail_case("address of number literal", R"SOURCE( |
| 1042 | const x = 3; | 1041 | const x = 3; |
| 1043 | const y = &x; | 1042 | const y = &x; |
| 1044 | )SOURCE", 1, ".tmp_source.zig:3:12: error: unable to get address of type '(integer literal)'"); | 1043 | fn foo() -> &const i32 { y } |
| 1045 | | 1044 | )SOURCE", 1, ".tmp_source.zig:4:26: error: expected type '&const i32', found '&const (integer literal)'"); |
| 1046 | add_compile_fail_case("@typeOf number literal", R"SOURCE( | | |
| 1047 | const x = 3; | | |
| 1048 | const Foo = struct { | | |
| 1049 | index: @typeOf(x), | | |
| 1050 | }; | | |
| 1051 | )SOURCE", 1, ".tmp_source.zig:4:20: error: type '(integer literal)' not eligible for @typeOf"); | | |
| 1052 | | 1045 | |
| 1053 | add_compile_fail_case("integer overflow error", R"SOURCE( | 1046 | add_compile_fail_case("integer overflow error", R"SOURCE( |
| 1054 | const x : u8 = 300; | 1047 | const x : u8 = 300; |
| ... | @@ -1077,7 +1070,7 @@ const members = []member_fn_type { | ... | @@ -1077,7 +1070,7 @@ const members = []member_fn_type { |
| 1077 | Foo.member_b, | 1070 | Foo.member_b, |
| 1078 | }; | 1071 | }; |
| 1079 | | 1072 | |
| 1080 | fn f(foo: Foo, index: i32) { | 1073 | fn f(foo: Foo, index: usize) { |
| 1081 | const result = members[index](); | 1074 | const result = members[index](); |
| 1082 | } | 1075 | } |
| 1083 | )SOURCE", 1, ".tmp_source.zig:21:34: error: expected 1 arguments, found 0"); | 1076 | )SOURCE", 1, ".tmp_source.zig:21:34: error: expected 1 arguments, found 0"); |
| ... | @@ -1094,10 +1087,7 @@ const fns = []fn(){ a, b, c }; | ... | @@ -1094,10 +1087,7 @@ const fns = []fn(){ a, b, c }; |
| 1094 | fn a() -> i32 {0} | 1087 | fn a() -> i32 {0} |
| 1095 | fn b() -> i32 {1} | 1088 | fn b() -> i32 {1} |
| 1096 | fn c() -> i32 {2} | 1089 | fn c() -> i32 {2} |
| 1097 | )SOURCE", 3, | 1090 | )SOURCE", 1, ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'"); |
| 1098 | ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'", | | |
| 1099 | ".tmp_source.zig:2:24: error: expected type 'fn()', found 'fn() -> i32'", | | |
| 1100 | ".tmp_source.zig:2:27: error: expected type 'fn()', found 'fn() -> i32'"); | | |
| 1101 | | 1091 | |
| 1102 | add_compile_fail_case("extern function pointer mismatch", R"SOURCE( | 1092 | add_compile_fail_case("extern function pointer mismatch", R"SOURCE( |
| 1103 | const fns = [](fn(i32)->i32){ a, b, c }; | 1093 | const fns = [](fn(i32)->i32){ a, b, c }; |
| ... | @@ -1126,11 +1116,11 @@ const x = @compileVar("bogus"); | ... | @@ -1126,11 +1116,11 @@ const x = @compileVar("bogus"); |
| 1126 | )SOURCE", 1, ".tmp_source.zig:2:23: error: unrecognized compile variable: 'bogus'"); | 1116 | )SOURCE", 1, ".tmp_source.zig:2:23: error: unrecognized compile variable: 'bogus'"); |
| 1127 | | 1117 | |
| 1128 | | 1118 | |
| 1129 | add_compile_fail_case("@constEval", R"SOURCE( | 1119 | add_compile_fail_case("@staticEval", R"SOURCE( |
| 1130 | fn a(x: i32) { | 1120 | fn a(x: i32) { |
| 1131 | const y = @constEval(x); | 1121 | const y = @staticEval(x); |
| 1132 | } | 1122 | } |
| 1133 | )SOURCE", 1, ".tmp_source.zig:3:26: error: unable to evaluate constant expression"); | 1123 | )SOURCE", 1, ".tmp_source.zig:3:27: error: unable to evaluate constant expression"); |
| 1134 | | 1124 | |
| 1135 | add_compile_fail_case("non constant expression in array size outside function", R"SOURCE( | 1125 | add_compile_fail_case("non constant expression in array size outside function", R"SOURCE( |
| 1136 | const Foo = struct { | 1126 | const Foo = struct { |