Hint at use of and/or when &&/|| is improperly used (#1886)
This commit is contained in:
committed by
Jimmi Holst Christensen
parent
3bec3b9f9b
commit
5bf9ffdc5b
@@ -1,6 +1,36 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"Use of && in place of `and`",
|
||||
\\export fn entry() void {
|
||||
\\ if (true && false) return;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:14: error: expected token ')', found '&&'",
|
||||
".tmp_source.zig:2:14: note: did you mean to use `and`?",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"Use of || in place of `or` (using comptime_int)",
|
||||
\\export fn entry() void {
|
||||
\\ if (1 || 0) return;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:9: error: expected ErrorSet type, found 'comptime_int'",
|
||||
".tmp_source.zig:2:11: note: did you mean to use `or`?",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"Use of || in place of `or` (using booleans)",
|
||||
\\export fn entry() void {
|
||||
\\ if (true || false) return;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:9: error: expected ErrorSet type, found 'bool'",
|
||||
".tmp_source.zig:2:14: note: did you mean to use `or`?",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"compile log a pointer to an opaque value",
|
||||
\\export fn entry() void {
|
||||
@@ -68,7 +98,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ do_the_thing(bar);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:4:18: error: expected type 'fn(i32) void', found 'fn(bool) void",
|
||||
".tmp_source.zig:4:18: error: expected 'fn(i32) void' type, found 'fn(bool) void",
|
||||
".tmp_source.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",
|
||||
);
|
||||
|
||||
@@ -104,7 +134,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
,
|
||||
".tmp_source.zig:3:31: error: integer value 300 cannot be implicitly casted to type 'u8'",
|
||||
".tmp_source.zig:7:22: error: integer value 300 cannot be implicitly casted to type 'u8'",
|
||||
".tmp_source.zig:11:20: error: expected type 'u8', found 'u16'",
|
||||
".tmp_source.zig:11:20: error: expected 'u8' type, found 'u16'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -124,7 +154,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(y)); }
|
||||
,
|
||||
".tmp_source.zig:2:14: error: expected type 'f32', found 'f64'",
|
||||
".tmp_source.zig:2:14: error: expected 'f32' type, found 'f64'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -172,7 +202,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var ptr2: *c_void = &b;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:5:26: error: expected type '*c_void', found '**u32'",
|
||||
".tmp_source.zig:5:26: error: expected '*c_void' type, found '**u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -222,7 +252,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ const sliceA: []u8 = &buffer;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:27: error: expected type '[]u8', found '*const [1]u8'",
|
||||
".tmp_source.zig:3:27: error: expected '[]u8' type, found '*const [1]u8'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -267,8 +297,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ const Errors = error{} || u16;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:20: error: expected error set type, found 'u8'",
|
||||
".tmp_source.zig:5:31: error: expected error set type, found 'u16'",
|
||||
".tmp_source.zig:2:20: error: expected ErrorSet type, found 'u8'",
|
||||
".tmp_source.zig:2:23: note: did you mean to use `or`?",
|
||||
".tmp_source.zig:5:31: error: expected ErrorSet type, found 'u16'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -763,7 +794,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\fn bar(x: *b.Foo) void {}
|
||||
,
|
||||
".tmp_source.zig:6:10: error: expected type '*Foo', found '*Foo'",
|
||||
".tmp_source.zig:6:10: error: expected '*Foo' type, found '*Foo'",
|
||||
".tmp_source.zig:6:10: note: pointer type child 'Foo' cannot cast into pointer type child 'Foo'",
|
||||
"a.zig:1:17: note: Foo declared here",
|
||||
"b.zig:1:17: note: Foo declared here",
|
||||
@@ -833,7 +864,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var y = p.*;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:4:23: error: expected type '*?*i32', found '**i32'",
|
||||
".tmp_source.zig:4:23: error: expected '*?*i32' type, found '**i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -842,7 +873,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ const x: [*]const bool = true;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:30: error: expected type '[*]const bool', found 'bool'",
|
||||
".tmp_source.zig:2:30: error: expected '[*]const bool' type, found 'bool'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -887,7 +918,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var rule_set = try Foo.init();
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:13: error: expected type 'i32', found 'type'",
|
||||
".tmp_source.zig:2:13: error: expected 'i32' type, found 'type'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -921,7 +952,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return null;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:5:34: error: expected type '?NextError!i32', found '?OtherError!i32'",
|
||||
".tmp_source.zig:5:34: error: expected '?NextError!i32' type, found '?OtherError!i32'",
|
||||
".tmp_source.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32'",
|
||||
".tmp_source.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError'",
|
||||
".tmp_source.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set",
|
||||
@@ -991,7 +1022,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ @panic(e);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:12: error: expected type '[]const u8', found 'error{Foo}'",
|
||||
".tmp_source.zig:3:12: error: expected '[]const u8' type, found 'error{Foo}'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1019,7 +1050,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return error.ShouldBeCompileError;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:6:17: error: expected type 'void', found 'error{ShouldBeCompileError}'",
|
||||
".tmp_source.zig:6:17: error: expected 'void' type, found 'error{ShouldBeCompileError}'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1062,7 +1093,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ a(c);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:8:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
|
||||
".tmp_source.zig:8:7: error: expected 'fn(*const u8) void' type, found 'fn(u8) void'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1144,7 +1175,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ E.One => {},
|
||||
\\ }
|
||||
\\}
|
||||
, ".tmp_source.zig:9:10: error: expected type 'usize', found 'E'");
|
||||
, ".tmp_source.zig:9:10: error: expected 'usize' type, found 'E'");
|
||||
|
||||
cases.add(
|
||||
"range operator in switch used on error set",
|
||||
@@ -1190,7 +1221,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ const z = i32!i32;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:15: error: expected error set type, found type 'i32'",
|
||||
".tmp_source.zig:2:15: error: expected ErrorSet type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1240,7 +1271,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return error.B;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:35: error: expected type 'SmallErrorSet!i32', found 'anyerror!i32'",
|
||||
".tmp_source.zig:3:35: error: expected 'SmallErrorSet!i32' type, found 'anyerror!i32'",
|
||||
".tmp_source.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet'",
|
||||
".tmp_source.zig:3:35: note: cannot cast global error set into smaller set",
|
||||
);
|
||||
@@ -1255,7 +1286,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return error.B;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:31: error: expected type 'SmallErrorSet', found 'anyerror'",
|
||||
".tmp_source.zig:3:31: error: expected 'SmallErrorSet' type, found 'anyerror'",
|
||||
".tmp_source.zig:3:31: note: cannot cast global error set into smaller set",
|
||||
);
|
||||
|
||||
@@ -1282,7 +1313,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var x: Set2 = set1;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:7:19: error: expected type 'Set2', found 'Set1'",
|
||||
".tmp_source.zig:7:19: error: expected 'Set2' type, found 'Set1'",
|
||||
".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",
|
||||
);
|
||||
|
||||
@@ -1822,7 +1853,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\fn a() noreturn {return;}
|
||||
\\export fn entry() void { a(); }
|
||||
,
|
||||
".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'",
|
||||
".tmp_source.zig:1:18: error: expected 'noreturn' type, found 'void'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1830,7 +1861,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\fn a() i32 {}
|
||||
\\export fn entry() void { _ = a(); }
|
||||
,
|
||||
".tmp_source.zig:1:12: error: expected type 'i32', found 'void'",
|
||||
".tmp_source.zig:1:12: error: expected 'i32' type, found 'void'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1936,7 +1967,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return a;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:12: error: expected type 'i32', found '[*]const u8'",
|
||||
".tmp_source.zig:3:12: error: expected 'i32' type, found '[*]const u8'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -1945,7 +1976,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ if (0) {}
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:9: error: expected type 'bool', found 'comptime_int'",
|
||||
".tmp_source.zig:2:9: error: expected 'bool' type, found 'comptime_int'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -2040,8 +2071,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ array[bad] = array[bad];
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
|
||||
".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'",
|
||||
".tmp_source.zig:4:11: error: expected 'usize' type, found 'bool'",
|
||||
".tmp_source.zig:4:24: error: expected 'usize' type, found 'bool'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -2455,7 +2486,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\fn foo() *const i32 { return y; }
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
|
||||
,
|
||||
".tmp_source.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
|
||||
".tmp_source.zig:3:30: error: expected '*const i32' type, found '*const comptime_int'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -2533,7 +2564,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\fn c() i32 {return 2;}
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
|
||||
,
|
||||
".tmp_source.zig:1:27: error: expected type 'fn() void', found 'fn() i32'",
|
||||
".tmp_source.zig:1:27: error: expected 'fn() void' type, found 'fn() i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -2545,7 +2576,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
|
||||
,
|
||||
".tmp_source.zig:1:36: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
|
||||
".tmp_source.zig:1:36: error: expected 'fn(i32) i32' type, found 'extern fn(i32) i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -2649,7 +2680,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(a)); }
|
||||
,
|
||||
".tmp_source.zig:1:16: error: expected type '*u8', found '(null)'",
|
||||
".tmp_source.zig:1:16: error: expected '*u8' type, found '(null)'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3289,7 +3320,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
\\fn something() anyerror!void { }
|
||||
,
|
||||
".tmp_source.zig:2:5: error: expected type 'void', found 'anyerror'",
|
||||
".tmp_source.zig:2:5: error: expected 'void' type, found 'anyerror'",
|
||||
".tmp_source.zig:1:15: note: return type declared here",
|
||||
);
|
||||
|
||||
@@ -3468,7 +3499,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ derp.init();
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:14:5: error: expected type 'i32', found 'Foo'",
|
||||
".tmp_source.zig:14:5: error: expected 'i32' type, found 'Foo'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3498,7 +3529,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ x.init();
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:23:5: error: expected type '*Allocator', found '*List'",
|
||||
".tmp_source.zig:23:5: error: expected '*Allocator' type, found '*List'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3670,7 +3701,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
|
||||
,
|
||||
".tmp_source.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'",
|
||||
".tmp_source.zig:8:26: error: expected '*const u3' type, found '*align(:3:1) const u3'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3799,7 +3830,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
|
||||
,
|
||||
".tmp_source.zig:4:19: error: expected type '*[]const u8', found '*const []const u8'",
|
||||
".tmp_source.zig:4:19: error: expected '*[]const u8' type, found '*const []const u8'",
|
||||
);
|
||||
|
||||
cases.addCase(x: {
|
||||
@@ -3831,7 +3862,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ foo(global_array);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:4:9: error: expected type '[]i32', found '[10]i32'",
|
||||
".tmp_source.zig:4:9: error: expected '[]i32' type, found '[10]i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3840,7 +3871,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return @ptrCast(usize, a);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:21: error: expected pointer, found 'usize'",
|
||||
".tmp_source.zig:2:21: error: expected Pointer type, found 'usize'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3887,7 +3918,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return @fieldParentPtr(Foo, "a", a);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:28: error: expected struct type, found 'i32'",
|
||||
".tmp_source.zig:3:28: error: expected Struct type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3911,7 +3942,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return @fieldParentPtr(Foo, "a", a);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:5:38: error: expected pointer, found 'i32'",
|
||||
".tmp_source.zig:5:38: error: expected Pointer type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -3952,7 +3983,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return @byteOffsetOf(Foo, "a",);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:26: error: expected struct type, found 'i32'",
|
||||
".tmp_source.zig:3:26: error: expected Struct type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4066,7 +4097,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
\\fn bar() ?i32 { return 1; }
|
||||
,
|
||||
".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'",
|
||||
".tmp_source.zig:2:15: error: expected 'bool' type, found '?i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4076,7 +4107,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
\\fn bar() anyerror!i32 { return 1; }
|
||||
,
|
||||
".tmp_source.zig:2:15: error: expected type 'bool', found 'anyerror!i32'",
|
||||
".tmp_source.zig:2:15: error: expected 'bool' type, found 'anyerror!i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4337,7 +4368,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return @ptrToInt(x);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:22: error: expected pointer, found 'i32'",
|
||||
".tmp_source.zig:2:22: error: expected Pointer type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4373,7 +4404,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return x << y;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'",
|
||||
".tmp_source.zig:2:17: error: expected 'u3' type, found 'u8'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4402,7 +4433,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ x.* += 1;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:8:13: error: expected type '*u32', found '*align(1) u32'",
|
||||
".tmp_source.zig:8:13: error: expected '*u32' type, found '*align(1) u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4446,7 +4477,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ @alignCast(4, u32(3));
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'",
|
||||
".tmp_source.zig:2:22: error: expected pointer or slice type, found 'u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4459,7 +4490,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
\\fn alignedSmall() align(4) i32 { return 1234; }
|
||||
,
|
||||
".tmp_source.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32'",
|
||||
".tmp_source.zig:2:35: error: expected 'fn() align(8) i32' type, found 'fn() align(4) i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4471,7 +4502,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ return x == 5678;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:4:32: error: expected type '*i32', found '*align(1) i32'",
|
||||
".tmp_source.zig:4:32: error: expected '*i32' type, found '*align(1) i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4506,7 +4537,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ bar(@ptrCast(*c_void, &x));
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:5:9: error: expected type '*Derp', found '*c_void'",
|
||||
".tmp_source.zig:5:9: error: expected '*Derp' type, found '*c_void'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4552,7 +4583,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'",
|
||||
".tmp_source.zig:3:50: error: expected 'AtomicOrder' type, found 'u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4562,7 +4593,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ @export("entry", entry, u32(1234));
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'",
|
||||
".tmp_source.zig:3:32: error: expected 'GlobalLinkage' type, found 'u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4739,7 +4770,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ _ = @ArgType(i32, 3);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:18: error: expected function, found 'i32'",
|
||||
".tmp_source.zig:2:18: error: expected Fn type, found 'i32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4837,7 +4868,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
\\pub extern fn foo(format: *const u8, ...) void;
|
||||
,
|
||||
".tmp_source.zig:2:9: error: expected type '*const u8', found '[5]u8'",
|
||||
".tmp_source.zig:2:9: error: expected '*const u8' type, found '[5]u8'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4906,7 +4937,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var x: u2 = Small.Two;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'",
|
||||
".tmp_source.zig:9:22: error: expected 'u2' type, found 'Small'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -4923,7 +4954,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var x = @intToEnum(Small, y);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:10:31: error: expected type 'u2', found 'u3'",
|
||||
".tmp_source.zig:10:31: error: expected 'u2' type, found 'u3'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -5320,7 +5351,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ asm volatile ("" : : [bar]"r"(3) : "");
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_int",
|
||||
".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_int",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
@@ -5329,6 +5360,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ asm volatile ("" : : [bar]"r"(3.17) : "");
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_float",
|
||||
".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_float",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user