mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
tests: get cases passing (and a few other bits)
This commit is contained in:
parent
3ffa8d83a3
commit
e415d725d3
94 changed files with 7775 additions and 7854 deletions
|
|
@ -718,7 +718,7 @@ export fn zig_med_struct_ints(s: MedStructInts) void {
|
|||
expect(s.z == 3) catch @panic("test failure");
|
||||
}
|
||||
|
||||
const SmallPackedStruct = packed struct {
|
||||
const SmallPackedStruct = packed struct(u8) {
|
||||
a: u2,
|
||||
b: u2,
|
||||
c: u2,
|
||||
|
|
@ -744,7 +744,7 @@ test "C ABI small packed struct" {
|
|||
try expect(s2.d == 3);
|
||||
}
|
||||
|
||||
const BigPackedStruct = packed struct {
|
||||
const BigPackedStruct = packed struct(u128) {
|
||||
a: u64,
|
||||
b: u64,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -116,13 +116,13 @@ export fn testMutablePointer() void {
|
|||
// tmp.zig:85:26: note: ZON does not allow nested optionals
|
||||
// tmp.zig:90:29: error: type '*i32' is not available in ZON
|
||||
// tmp.zig:90:29: note: ZON does not allow mutable pointers
|
||||
// neg_inf.zon:1:1: error: expected type '@EnumLiteral()'
|
||||
// tmp.zig:37:38: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type '?u8'
|
||||
// tmp.zig:57:28: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type '@EnumLiteral()'
|
||||
// tmp.zig:37:38: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.E'
|
||||
// tmp.zig:63:26: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.U'
|
||||
// tmp.zig:69:26: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.EU'
|
||||
// tmp.zig:75:27: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.U'
|
||||
// tmp.zig:69:26: note: imported here
|
||||
|
|
|
|||
|
|
@ -58,25 +58,25 @@ export fn testVector() void {
|
|||
// error
|
||||
// imports=zon/vec2.zon
|
||||
//
|
||||
// vec2.zon:1:2: error: expected type '?f32'
|
||||
// tmp.zig:2:29: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '*const ?f32'
|
||||
// tmp.zig:7:36: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?*const f32'
|
||||
// tmp.zig:12:36: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?@EnumLiteral()'
|
||||
// tmp.zig:33:39: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?@Vector(3, f32)'
|
||||
// tmp.zig:54:41: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?[1]u8'
|
||||
// tmp.zig:38:31: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?[]const u8'
|
||||
// tmp.zig:49:36: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?bool'
|
||||
// tmp.zig:17:30: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?f32'
|
||||
// tmp.zig:2:29: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?i32'
|
||||
// tmp.zig:22:29: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?tmp.Enum'
|
||||
// tmp.zig:28:30: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?@EnumLiteral()'
|
||||
// tmp.zig:33:39: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?[1]u8'
|
||||
// tmp.zig:38:31: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?tmp.Union'
|
||||
// tmp.zig:44:31: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?[]const u8'
|
||||
// tmp.zig:49:36: note: imported here
|
||||
// vec2.zon:1:2: error: expected type '?@Vector(3, f32)'
|
||||
// tmp.zig:54:41: note: imported here
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export fn testTuple() void {
|
|||
// error
|
||||
// imports=zon/nan.zon
|
||||
//
|
||||
//nan.zon:1:1: error: expected type '?tmp.Struct'
|
||||
//tmp.zig:3:32: note: imported here
|
||||
//nan.zon:1:1: error: expected type '?struct { bool }'
|
||||
//tmp.zig:9:31: note: imported here
|
||||
// nan.zon:1:1: error: expected type '?struct { bool }'
|
||||
// tmp.zig:9:31: note: imported here
|
||||
// nan.zon:1:1: error: expected type '?tmp.Struct'
|
||||
// tmp.zig:3:32: note: imported here
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
const x = 42;
|
||||
const y = @intFromPtr(&x);
|
||||
pub export fn entry() void {
|
||||
_ = y;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:23: error: comptime-only type 'comptime_int' has no pointer address
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
const Foo = struct { a: u32 };
|
||||
export fn a() void {
|
||||
const T = [*c]Foo;
|
||||
const t: T = undefined;
|
||||
_ = t;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:19: error: C pointers cannot point to non-C-ABI-compatible type 'tmp.Foo'
|
||||
// :3:19: note: only extern structs and ABI sized packed structs are extern compatible
|
||||
// :1:13: note: struct declared here
|
||||
|
|
@ -12,16 +12,14 @@ const U = union {
|
|||
b: [1 << 32]u8,
|
||||
};
|
||||
|
||||
const V = union {
|
||||
a: u32,
|
||||
b: T,
|
||||
};
|
||||
|
||||
comptime {
|
||||
_ = S;
|
||||
_ = T;
|
||||
_ = U;
|
||||
_ = V;
|
||||
_ = @as(S, undefined);
|
||||
}
|
||||
comptime {
|
||||
_ = @as(T, undefined);
|
||||
}
|
||||
comptime {
|
||||
_ = @as(U, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ export fn entry1() usize {
|
|||
// error
|
||||
//
|
||||
// :2:21: error: no align available for uninstantiable type 'noreturn'
|
||||
// :6:21: error: no align available for uninstantiable type 'alignOf_bad_type.S'
|
||||
// :6:21: error: no align available for uninstantiable type 'tmp.S'
|
||||
// :4:11: note: struct declared here
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ export fn g() void {
|
|||
}
|
||||
|
||||
export fn h() void {
|
||||
_ = struct { field: i32 align(0) };
|
||||
_ = @as(struct { field: i32 align(0) }, undefined);
|
||||
}
|
||||
|
||||
export fn i() void {
|
||||
_ = union { field: i32 align(0) };
|
||||
_ = @as(union { field: i32 align(0) }, undefined);
|
||||
}
|
||||
|
||||
export fn j() void {
|
||||
|
|
@ -54,7 +54,7 @@ export fn k() void {
|
|||
// :20:30: error: alignment must be >= 1
|
||||
// :25:16: error: alignment must be >= 1
|
||||
// :29:17: error: alignment must be >= 1
|
||||
// :33:35: error: alignment must be >= 1
|
||||
// :37:34: error: alignment must be >= 1
|
||||
// :33:39: error: alignment must be >= 1
|
||||
// :37:38: error: alignment must be >= 1
|
||||
// :41:51: error: alignment must be >= 1
|
||||
// :45:25: error: alignment must be >= 1
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
export fn entry() void {
|
||||
var a = &b;
|
||||
_ = &a;
|
||||
}
|
||||
inline fn b() void {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:9: error: variable of type '*const fn () callconv(.@"inline") void' must be const or comptime
|
||||
// :2:9: note: function has inline calling convention
|
||||
|
|
@ -16,7 +16,11 @@ export fn entry3() void {
|
|||
// error
|
||||
//
|
||||
// :3:23: error: bit-pointer cannot refer to value of type 'tmp.entry1.S'
|
||||
// :3:23: note: only packed structs layout are allowed in packed types
|
||||
// :3:23: note: non-packed structs do not have a bit-packed representation
|
||||
// :2:22: note: struct declared here
|
||||
// :8:36: error: bit-pointer cannot refer to value of type 'tmp.entry2.S'
|
||||
// :8:36: note: only packed structs layout are allowed in packed types
|
||||
// :8:36: note: non-packed structs do not have a bit-packed representation
|
||||
// :7:15: note: struct declared here
|
||||
// :13:23: error: bit-pointer cannot refer to value of type 'tmp.entry3.E'
|
||||
// :12:15: note: integer tag type of enum is inferred
|
||||
// :12:15: note: consider explicitly specifying the integer tag type
|
||||
|
|
|
|||
|
|
@ -8,4 +8,6 @@ pub export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:27: error: backing integer type 'u32' has bit size 32 but the struct fields have a total bit size of 1
|
||||
// :1:20: error: backing integer bit width does not match total bit width of fields
|
||||
// :1:27: note: backing integer 'u32' has bit width '32'
|
||||
// :1:20: note: struct fields have total bit width '1'
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
export fn entry() void {
|
||||
const a: [*c]void = undefined;
|
||||
_ = a;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:18: error: C pointers cannot point to non-C-ABI-compatible type 'void'
|
||||
// :2:18: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
export fn entry() void {
|
||||
var a = &b;
|
||||
a = a;
|
||||
a();
|
||||
}
|
||||
inline fn b() void {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:5: error: unable to resolve comptime value
|
||||
// :4:5: note: function being called inline must be comptime-known
|
||||
|
|
@ -40,13 +40,13 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :6:20: error: expected type 'f16', found 'u12'
|
||||
// :6:20: error: expected type 'f16', found 'i13'
|
||||
// :6:20: error: expected type 'f32', found 'u25'
|
||||
// :6:20: error: expected type 'f32', found 'i26'
|
||||
// :6:20: error: expected type 'f64', found 'u54'
|
||||
// :6:20: error: expected type 'f64', found 'i55'
|
||||
// :6:20: error: expected type 'f80', found 'u65'
|
||||
// :6:20: error: expected type 'f80', found 'i66'
|
||||
// :6:20: error: expected type 'f128', found 'u114'
|
||||
// :6:20: error: expected type 'f128', found 'i115'
|
||||
// :6:20: error: expected type 'f128', found 'u114'
|
||||
// :6:20: error: expected type 'f16', found 'i13'
|
||||
// :6:20: error: expected type 'f16', found 'u12'
|
||||
// :6:20: error: expected type 'f32', found 'i26'
|
||||
// :6:20: error: expected type 'f32', found 'u25'
|
||||
// :6:20: error: expected type 'f64', found 'i55'
|
||||
// :6:20: error: expected type 'f64', found 'u54'
|
||||
// :6:20: error: expected type 'f80', found 'i66'
|
||||
// :6:20: error: expected type 'f80', found 'u65'
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ comptime {
|
|||
// error
|
||||
//
|
||||
// :7:16: error: captured value contains reference to comptime var
|
||||
// :7:16: note: 'wrapper' points to '@as(*const tmp.Wrapper, @ptrCast(&v0)).*', where
|
||||
// :7:16: note: 'wrapper' points to 'v0', where
|
||||
// :16:5: note: 'v0.ptr' points to comptime var declared here
|
||||
// :17:29: note: called at comptime here
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: struct 'tmp.A' depends on itself
|
||||
// :2:8: error: type 'tmp.A' depends on itself for field declared here
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@ export fn d() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :3:8: error: opaque types have unknown size and therefore cannot be directly embedded in structs
|
||||
// :3:8: error: cannot directly embed opaque type 'tmp.O' in struct
|
||||
// :3:8: note: opaque types have unknown size
|
||||
// :1:11: note: opaque declared here
|
||||
// :7:10: error: opaque types have unknown size and therefore cannot be directly embedded in unions
|
||||
// :7:10: error: cannot directly embed opaque type 'tmp.O' in union
|
||||
// :7:10: note: opaque types have unknown size
|
||||
// :1:11: note: opaque declared here
|
||||
// :18:24: error: cannot cast to opaque type 'tmp.O'
|
||||
// :1:11: note: opaque declared here
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
pub const Foo = enum(c_int) {
|
||||
A = Foo.B,
|
||||
C = D,
|
||||
|
||||
pub const B = 0;
|
||||
a = 10,
|
||||
b = @intFromEnum(Foo.a) - 1,
|
||||
};
|
||||
export fn entry() void {
|
||||
const s: Foo = Foo.E;
|
||||
_ = s;
|
||||
_ = @as(Foo, .a);
|
||||
}
|
||||
const D = 1;
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:5: error: dependency loop detected
|
||||
// :3:25: error: type 'tmp.Foo' depends on itself for field usage here
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ const D = 1;
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:5: error: dependency loop detected
|
||||
// :2:12: error: type 'tmp.Foo' depends on itself for field usage here
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :6:9: error: enum tag value 60 already taken
|
||||
// :4:9: note: other occurrence here
|
||||
// :6:9: error: enum tag value '60' for field 'E' already taken
|
||||
// :4:9: note: previous occurrence in field 'C'
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@ pub fn main() Error!void {
|
|||
// error
|
||||
// target=x86_64-linux
|
||||
//
|
||||
// :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).@"fn".return_type.?).error_union.error_set'
|
||||
// :23:29: error: expected type 'error{InvalidCharacter}!void', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).@"fn".return_type.?).error_union.error_set'
|
||||
// :23:29: note: 'error.InvalidDirection' not a member of destination error set
|
||||
// :22:20: note: function return type declared here
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ comptime {
|
|||
// error
|
||||
// target=x86_64-linux
|
||||
//
|
||||
// :8:41: error: expected type '*align(2) const fn () void', found '*const fn () void'
|
||||
// :8:41: error: expected type '*align(2) const fn () void', found '*align(1) const fn () void'
|
||||
// :8:41: note: pointer alignment '1' cannot cast into pointer alignment '2'
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ export fn entry(foo: Foo) void {
|
|||
// target=x86_64-linux
|
||||
//
|
||||
// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'x86_64_sysv'
|
||||
// :6:17: note: only extern structs and ABI sized packed structs are extern compatible
|
||||
// :6:17: note: struct with automatic layout has no guaranteed in-memory representation
|
||||
// :1:13: note: struct declared here
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ export fn entry(foo: Foo) void {
|
|||
// target=x86_64-linux
|
||||
//
|
||||
// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'x86_64_sysv'
|
||||
// :6:17: note: only extern unions and ABI sized packed unions are extern compatible
|
||||
// :6:17: note: union with automatic layout has no guaranteed in-memory representation
|
||||
// :1:13: note: union declared here
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ export fn bar() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:30: error: opaque return type 'anyopaque' not allowed
|
||||
// :1:30: error: opaque return type 'tmp.MyOpaque' not allowed
|
||||
// :4:18: note: opaque declared here
|
||||
// :1:30: error: opaque return type 'anyopaque' not allowed
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ export fn foo() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :3:27: error: indexing into empty array is not allowed
|
||||
// :3:27: error: cannot index into empty array
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ export fn foo() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :5:27: error: indexing into empty array is not allowed
|
||||
// :5:27: error: cannot index into empty array
|
||||
|
|
|
|||
|
|
@ -13,4 +13,8 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: struct 'tmp.A' depends on itself
|
||||
// error: dependency loop with length 3
|
||||
// :2:8: note: type 'tmp.A' depends on type 'tmp.B' for field declared here
|
||||
// :5:8: note: type 'tmp.B' depends on type 'tmp.C' for field declared here
|
||||
// :8:8: note: type 'tmp.C' depends on type 'tmp.A' for field declared here
|
||||
// note: eliminate any one of these dependencies to break the loop
|
||||
|
|
|
|||
|
|
@ -49,33 +49,33 @@ export fn deref5(ptr: *const U5) void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :13:17: error: expected type 'initialize_empty_union.U0', found '@TypeOf(undefined)'
|
||||
// :13:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U0'
|
||||
// :13:17: error: expected type 'tmp.U0', found '@TypeOf(undefined)'
|
||||
// :13:17: note: cannot coerce to uninstantiable type 'tmp.U0'
|
||||
// :5:12: note: union declared here
|
||||
// :16:17: error: expected type 'initialize_empty_union.U1', found '@TypeOf(undefined)'
|
||||
// :16:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U1'
|
||||
// :16:17: error: expected type 'tmp.U1', found '@TypeOf(undefined)'
|
||||
// :16:17: note: cannot coerce to uninstantiable type 'tmp.U1'
|
||||
// :6:12: note: union declared here
|
||||
// :19:17: error: expected type 'initialize_empty_union.U2', found '@TypeOf(undefined)'
|
||||
// :19:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U2'
|
||||
// :19:17: error: expected type 'tmp.U2', found '@TypeOf(undefined)'
|
||||
// :19:17: note: cannot coerce to uninstantiable type 'tmp.U2'
|
||||
// :7:12: note: union declared here
|
||||
// :22:17: error: expected type 'initialize_empty_union.U3', found '@TypeOf(undefined)'
|
||||
// :22:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U3'
|
||||
// :22:17: error: expected type 'tmp.U3', found '@TypeOf(undefined)'
|
||||
// :22:17: note: cannot coerce to uninstantiable type 'tmp.U3'
|
||||
// :8:12: note: union declared here
|
||||
// :25:17: error: expected type 'initialize_empty_union.U4', found '@TypeOf(undefined)'
|
||||
// :25:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U4'
|
||||
// :25:17: error: expected type 'tmp.U4', found '@TypeOf(undefined)'
|
||||
// :25:17: note: cannot coerce to uninstantiable type 'tmp.U4'
|
||||
// :9:12: note: union declared here
|
||||
// :28:17: error: expected type 'initialize_empty_union.U5', found '@TypeOf(undefined)'
|
||||
// :28:17: note: cannot coerce to uninstantiable type 'initialize_empty_union.U5'
|
||||
// :28:17: error: expected type 'tmp.U5', found '@TypeOf(undefined)'
|
||||
// :28:17: note: cannot coerce to uninstantiable type 'tmp.U5'
|
||||
// :10:12: note: union declared here
|
||||
// :32:12: error: cannot load uninstantiable type 'initialize_empty_union.U0'
|
||||
// :32:12: error: cannot load uninstantiable type 'tmp.U0'
|
||||
// :5:12: note: union declared here
|
||||
// :35:12: error: cannot load uninstantiable type 'initialize_empty_union.U1'
|
||||
// :35:12: error: cannot load uninstantiable type 'tmp.U1'
|
||||
// :6:12: note: union declared here
|
||||
// :38:12: error: cannot load uninstantiable type 'initialize_empty_union.U2'
|
||||
// :38:12: error: cannot load uninstantiable type 'tmp.U2'
|
||||
// :7:12: note: union declared here
|
||||
// :41:12: error: cannot load uninstantiable type 'initialize_empty_union.U3'
|
||||
// :41:12: error: cannot load uninstantiable type 'tmp.U3'
|
||||
// :8:12: note: union declared here
|
||||
// :44:12: error: cannot load uninstantiable type 'initialize_empty_union.U4'
|
||||
// :44:12: error: cannot load uninstantiable type 'tmp.U4'
|
||||
// :9:12: note: union declared here
|
||||
// :47:12: error: cannot load uninstantiable type 'initialize_empty_union.U5'
|
||||
// :47:12: error: cannot load uninstantiable type 'tmp.U5'
|
||||
// :10:12: note: union declared here
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:13: error: struct 'tmp.Foo' depends on itself
|
||||
// :2:8: error: type 'tmp.Foo' depends on itself for field declared here
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:13: error: union 'tmp.Foo' depends on itself
|
||||
// :2:8: error: type 'tmp.Foo' depends on itself for field declared here
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
comptime {
|
||||
const S = struct {
|
||||
const Foo = struct {
|
||||
y: Bar,
|
||||
};
|
||||
const Bar = struct {
|
||||
y: if (@sizeOf(Foo) == 0) u64 else void,
|
||||
};
|
||||
const S = struct {
|
||||
const Foo = struct {
|
||||
y: Bar,
|
||||
};
|
||||
|
||||
const Bar = struct {
|
||||
y: if (@sizeOf(Foo) == 0) u64 else void,
|
||||
};
|
||||
};
|
||||
comptime {
|
||||
_ = @sizeOf(S.Foo) + 1;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:21: error: struct layout depends on it having runtime bits
|
||||
// error: dependency loop with length 2
|
||||
// :3:12: note: type 'tmp.S.Foo' depends on type 'tmp.S.Bar' for field declared here
|
||||
// :6:24: note: type 'tmp.S.Bar' depends on type 'tmp.S.Foo' for size query here
|
||||
// note: eliminate any one of these dependencies to break the loop
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ const stroo = extern struct {
|
|||
moo: ?[*c]u8,
|
||||
};
|
||||
export fn testf(fluff: *stroo) void {
|
||||
_ = fluff;
|
||||
_ = fluff.*;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:10: error: extern structs cannot contain fields of type '?[*c]u8'
|
||||
// :2:10: note: only pointer like optionals are extern compatible
|
||||
// :2:10: note: non-pointer optionals have no guaranteed in-memory representation
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ comptime {
|
|||
_ = x - y;
|
||||
}
|
||||
|
||||
comptime {
|
||||
const x: [*]u0 = @ptrFromInt(1);
|
||||
_ = x + 1;
|
||||
}
|
||||
|
||||
comptime {
|
||||
const x: *u0 = @ptrFromInt(1);
|
||||
const y: *u0 = @ptrFromInt(2);
|
||||
|
|
@ -46,5 +41,4 @@ comptime {
|
|||
// :12:11: error: invalid operands to binary expression: 'pointer' and 'pointer'
|
||||
// :20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16'
|
||||
// :26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16'
|
||||
// :31:11: error: pointer arithmetic requires element type 'u0' to have runtime bits
|
||||
// :37:11: error: pointer arithmetic requires element type 'u0' to have runtime bits
|
||||
// :32:11: error: pointer subtraction requires element type 'u0' to have runtime bits
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
const x = @extern(*comptime_int, .{ .name = "foo" });
|
||||
const y = @extern(*fn (u8) u8, .{ .name = "bar" });
|
||||
pub export fn entry() void {
|
||||
const z = @extern(*fn (u8) callconv(.c) u8, .{ .name = "bar" });
|
||||
comptime {
|
||||
_ = x;
|
||||
}
|
||||
pub export fn entry2() void {
|
||||
comptime {
|
||||
_ = y;
|
||||
}
|
||||
comptime {
|
||||
_ = z;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:19: error: extern symbol cannot have type '*comptime_int'
|
||||
// :1:19: note: pointer to comptime-only type 'comptime_int'
|
||||
// :1:19: note: pointer element type 'comptime_int' is not extern compatible
|
||||
// :2:19: error: extern symbol cannot have type '*fn (u8) u8'
|
||||
// :2:19: note: pointer to extern function must be 'const'
|
||||
// :2:19: note: pointer element type 'fn (u8) u8' is not extern compatible
|
||||
// :2:19: note: extern function must specify calling convention
|
||||
// :3:19: error: extern symbol cannot have type '*fn (u8) callconv(.c) u8'
|
||||
// :3:19: note: pointer to extern function must be 'const'
|
||||
|
|
|
|||
|
|
@ -1,49 +1,44 @@
|
|||
export fn entry1() void {
|
||||
var m2 = &2;
|
||||
_ = &m2;
|
||||
}
|
||||
export fn entry2() void {
|
||||
export fn entry0() void {
|
||||
var a = undefined;
|
||||
_ = &a;
|
||||
}
|
||||
export fn entry3() void {
|
||||
export fn entry1() void {
|
||||
var b = 1;
|
||||
_ = &b;
|
||||
}
|
||||
export fn entry4() void {
|
||||
export fn entry2() void {
|
||||
var c = 1.0;
|
||||
_ = &c;
|
||||
}
|
||||
export fn entry5() void {
|
||||
export fn entry3() void {
|
||||
var d = null;
|
||||
_ = &d;
|
||||
}
|
||||
export fn entry6(opaque_: *Opaque) void {
|
||||
export fn entry4(opaque_: *Opaque) void {
|
||||
var e = opaque_.*;
|
||||
_ = &e;
|
||||
}
|
||||
export fn entry7() void {
|
||||
export fn entry5() void {
|
||||
var f = i32;
|
||||
_ = &f;
|
||||
}
|
||||
const Opaque = opaque {};
|
||||
export fn entry8() void {
|
||||
export fn entry6() void {
|
||||
var e: Opaque = undefined;
|
||||
_ = &e;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:9: error: variable of type '*const comptime_int' must be const or comptime
|
||||
// :6:9: error: variable of type '@TypeOf(undefined)' must be const or comptime
|
||||
// :10:9: error: variable of type 'comptime_int' must be const or comptime
|
||||
// :2:9: error: variable of type '@TypeOf(undefined)' must be const or comptime
|
||||
// :6:9: error: variable of type 'comptime_int' must be const or comptime
|
||||
// :6:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
|
||||
// :10:9: error: variable of type 'comptime_float' must be const or comptime
|
||||
// :10:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
|
||||
// :14:9: error: variable of type 'comptime_float' must be const or comptime
|
||||
// :14:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
|
||||
// :18:9: error: variable of type '@TypeOf(null)' must be const or comptime
|
||||
// :22:20: error: cannot load opaque type 'tmp.Opaque'
|
||||
// :29:16: note: opaque declared here
|
||||
// :26:9: error: variable of type 'type' must be const or comptime
|
||||
// :26:9: note: types are not available at runtime
|
||||
// :31:12: error: non-extern variable with opaque type 'tmp.Opaque'
|
||||
// :29:16: note: opaque declared here
|
||||
// :14:9: error: variable of type '@TypeOf(null)' must be const or comptime
|
||||
// :18:20: error: cannot load opaque type 'tmp.Opaque'
|
||||
// :25:16: note: opaque declared here
|
||||
// :22:9: error: variable of type 'type' must be const or comptime
|
||||
// :22:9: note: types are not available at runtime
|
||||
// :27:12: error: non-extern variable with opaque type 'tmp.Opaque'
|
||||
// :25:16: note: opaque declared here
|
||||
|
|
|
|||
|
|
@ -3,18 +3,7 @@ const A = enum {
|
|||
b,
|
||||
_ = 1,
|
||||
};
|
||||
const B = enum {
|
||||
a,
|
||||
b,
|
||||
_,
|
||||
};
|
||||
comptime {
|
||||
_ = A;
|
||||
_ = B;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value
|
||||
// :6:11: error: non-exhaustive enum missing integer tag type
|
||||
// :9:5: note: marked non-exhaustive here
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
const E = enum {
|
||||
a,
|
||||
b,
|
||||
_,
|
||||
};
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: non-exhaustive enum missing integer tag type
|
||||
// :4:5: note: marked non-exhaustive here
|
||||
|
|
@ -4,7 +4,7 @@ const C = enum(u1) {
|
|||
_,
|
||||
};
|
||||
pub export fn entry() void {
|
||||
_ = C;
|
||||
_ = C.a;
|
||||
}
|
||||
|
||||
// error
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :7:10: error: values of type '[2]tmp.Foo' must be comptime-known, but index value is runtime-known
|
||||
// :7:10: error: values of type 'tmp.Foo' must be comptime-known, but index value is runtime-known
|
||||
// :3:8: note: struct requires comptime because of this field
|
||||
// :3:8: note: types are not available at runtime
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ export fn entry() usize {
|
|||
//
|
||||
// :6:12: error: unable to resolve comptime value
|
||||
// :2:12: note: called at comptime from here
|
||||
// :1:13: note: types must be comptime-known
|
||||
// :2:8: note: struct field types must be comptime-known
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
const S = struct {
|
||||
s: noreturn,
|
||||
};
|
||||
comptime {
|
||||
_ = @typeInfo(S);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:8: error: struct fields cannot be 'noreturn'
|
||||
|
|
@ -4,15 +4,9 @@ const S = extern struct {
|
|||
comptime {
|
||||
_ = @sizeOf(S) == 1;
|
||||
}
|
||||
comptime {
|
||||
_ = [*c][4]fn () callconv(.c) void;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:8: error: extern structs cannot contain fields of type 'fn () callconv(.c) void'
|
||||
// :2:8: note: type has no guaranteed in-memory representation
|
||||
// :2:8: note: use '*const ' to make a function pointer type
|
||||
// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn () callconv(.c) void'
|
||||
// :8:13: note: type has no guaranteed in-memory representation
|
||||
// :8:13: note: use '*const ' to make a function pointer type
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ pub export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: enumeration value '256' too large for type 'u8'
|
||||
// :3:5: error: enum tag value '256' too large for type 'u8'
|
||||
|
|
|
|||
|
|
@ -44,8 +44,12 @@ export fn entry7() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :2:31: error: backing integer type 'u32' has bit size 32 but the struct fields have a total bit size of 29
|
||||
// :9:31: error: backing integer type 'i31' has bit size 31 but the struct fields have a total bit size of 32
|
||||
// :2:24: error: backing integer bit width does not match total bit width of fields
|
||||
// :2:31: note: backing integer 'u32' has bit width '32'
|
||||
// :2:24: note: struct fields have total bit width '29'
|
||||
// :9:24: error: backing integer bit width does not match total bit width of fields
|
||||
// :9:31: note: backing integer 'i31' has bit width '31'
|
||||
// :9:24: note: struct fields have total bit width '32'
|
||||
// :17:31: error: expected backing integer type, found 'void'
|
||||
// :23:31: error: expected backing integer type, found 'void'
|
||||
// :27:31: error: expected backing integer type, found 'noreturn'
|
||||
|
|
|
|||
|
|
@ -85,29 +85,32 @@ export fn entry15() void {
|
|||
// error
|
||||
//
|
||||
// :3:12: error: packed structs cannot contain fields of type 'anyerror'
|
||||
// :3:12: note: type has no guaranteed in-memory representation
|
||||
// :3:12: note: type does not have a bit-packed representation
|
||||
// :8:12: error: packed structs cannot contain fields of type '[2]u24'
|
||||
// :8:12: note: type has no guaranteed in-memory representation
|
||||
// :8:12: note: type does not have a bit-packed representation
|
||||
// :13:20: error: packed structs cannot contain fields of type 'anyerror!u32'
|
||||
// :13:20: note: type has no guaranteed in-memory representation
|
||||
// :13:20: note: type does not have a bit-packed representation
|
||||
// :18:12: error: packed structs cannot contain fields of type 'tmp.S'
|
||||
// :18:12: note: only packed structs layout are allowed in packed types
|
||||
// :18:12: note: non-packed structs do not have a bit-packed representation
|
||||
// :56:11: note: struct declared here
|
||||
// :23:12: error: packed structs cannot contain fields of type 'tmp.U'
|
||||
// :23:12: note: only packed unions layout are allowed in packed types
|
||||
// :23:12: note: non-packed unions do not have a bit-packed representation
|
||||
// :59:18: note: union declared here
|
||||
// :28:12: error: packed structs cannot contain fields of type '?anyerror'
|
||||
// :28:12: note: type has no guaranteed in-memory representation
|
||||
// :28:12: note: type does not have a bit-packed representation
|
||||
// :38:12: error: packed structs cannot contain fields of type 'fn () void'
|
||||
// :38:12: note: type has no guaranteed in-memory representation
|
||||
// :38:12: note: use '*const ' to make a function pointer type
|
||||
// :38:12: note: type does not have a bit-packed representation
|
||||
// :43:12: error: packed structs cannot contain fields of type '*const fn () void'
|
||||
// :43:12: note: pointers cannot be directly bitpacked
|
||||
// :43:12: note: consider using 'usize' and '@intFromPtr'
|
||||
// :65:31: error: packed structs cannot contain fields of type '[]u8'
|
||||
// :65:31: note: slices have no guaranteed in-memory representation
|
||||
// :65:31: note: slices do not have a bit-packed representation
|
||||
// :70:12: error: packed structs cannot contain fields of type '*type'
|
||||
// :70:12: note: comptime-only pointer has no guaranteed in-memory representation
|
||||
// :70:12: note: types are not available at runtime
|
||||
// :70:12: note: pointers cannot be directly bitpacked
|
||||
// :70:12: note: consider using 'usize' and '@intFromPtr'
|
||||
// :76:12: error: packed structs cannot contain fields of type 'tmp.entry14.E'
|
||||
// :74:15: note: enum declared here
|
||||
// :74:15: note: integer tag type of enum is inferred
|
||||
// :74:15: note: consider explicitly specifying the integer tag type
|
||||
// :81:12: error: packed structs cannot contain fields of type '*const u32'
|
||||
// :81:12: note: pointers cannot be directly bitpacked
|
||||
// :81:12: note: consider using 'usize' and '@intFromPtr'
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
export fn entry1() void {
|
||||
_ = packed union {
|
||||
const U = packed union {
|
||||
a: u1,
|
||||
b: u2,
|
||||
};
|
||||
_ = @as(U, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:16: error: packed union has fields with mismatching bit sizes
|
||||
// :3:12: note: 1 bits here
|
||||
// :4:12: note: 2 bits here
|
||||
// :4:12: error: field bit width does not match earlier field
|
||||
// :4:12: note: field type 'u2' has bit width '2'
|
||||
// :3:12: note: other field type 'u1' has bit width '1'
|
||||
// :4:12: note: all fields in a packed union must have the same bit width
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
const Letter = enum {
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
};
|
||||
const Payload = packed union(Letter) {
|
||||
A: i32,
|
||||
B: f64,
|
||||
C: bool,
|
||||
};
|
||||
export fn entry() void {
|
||||
const a: Payload = .{ .A = 1234 };
|
||||
_ = a;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:30: error: packed union does not support enum tag type
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
const S = struct { a: u32 };
|
||||
export fn entry0() void {
|
||||
_ = @sizeOf(packed union {
|
||||
foo: struct { a: u32 },
|
||||
foo: S,
|
||||
bar: bool,
|
||||
});
|
||||
}
|
||||
|
|
@ -12,9 +13,9 @@ export fn entry1() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :3:14: error: packed unions cannot contain fields of type 'packed_union_with_fields_of_not_allowed_types.entry0__union_180__struct_182'
|
||||
// :3:14: note: non-packed structs do not have a bit-packed representation
|
||||
// :3:14: note: struct declared here
|
||||
// :9:12: error: packed unions cannot contain fields of type '*const u32'
|
||||
// :9:12: note: pointers cannot be directly bitpacked
|
||||
// :9:12: note: consider using 'usize' and '@intFromPtr'
|
||||
// :4:14: error: packed unions cannot contain fields of type 'tmp.S'
|
||||
// :4:14: note: non-packed structs do not have a bit-packed representation
|
||||
// :1:11: note: struct declared here
|
||||
// :10:12: error: packed unions cannot contain fields of type '*const u32'
|
||||
// :10:12: note: pointers cannot be directly bitpacked
|
||||
// :10:12: note: consider using 'usize' and '@intFromPtr'
|
||||
|
|
|
|||
22
test/cases/compile_errors/pointer_in_bitpack.zig
Normal file
22
test/cases/compile_errors/pointer_in_bitpack.zig
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
const S = packed struct {
|
||||
ptr: *u32,
|
||||
};
|
||||
export fn foo() void {
|
||||
_ = @as(S, undefined);
|
||||
}
|
||||
|
||||
const U = packed union {
|
||||
ptr: *u32,
|
||||
};
|
||||
export fn bar() void {
|
||||
_ = @as(U, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:10: error: packed structs cannot contain fields of type '*u32'
|
||||
// :2:10: note: pointers cannot be directly bitpacked
|
||||
// :2:10: note: consider using 'usize' and '@intFromPtr'
|
||||
// :9:10: error: packed unions cannot contain fields of type '*u32'
|
||||
// :9:10: note: pointers cannot be directly bitpacked
|
||||
// :9:10: note: consider using 'usize' and '@intFromPtr'
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
export fn entry() void {
|
||||
_ = @Enum(u32, .nonexhaustive, &.{ "A", "A" }, &.{ 0, 1 });
|
||||
const E = @Enum(u32, .nonexhaustive, &.{ "A", "A" }, &.{ 0, 1 });
|
||||
_ = @as(E, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:36: error: duplicate enum field 'A'
|
||||
// :2:36: note: other field here
|
||||
// :2:42: error: duplicate enum field 'A' at index '1'
|
||||
// :2:42: note: previous field at index '0'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
export fn entry() void {
|
||||
_ = @Enum(u32, .nonexhaustive, &.{ "A", "B" }, &.{ 10, 10 });
|
||||
const E = @Enum(u32, .nonexhaustive, &.{ "a", "b" }, &.{ 10, 10 });
|
||||
_ = E.a;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:52: error: enum tag value 10 already taken
|
||||
// :2:52: note: other enum tag value here
|
||||
// :2:58: error: enum tag value '10' for field 'b' already taken
|
||||
// :2:58: note: previous occurrence in field 'a'
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:19: error: tag type must be an integer type
|
||||
// :1:19: error: expected integer tag type, found 'bool'
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
const Tag = @Enum(u2, .exhaustive, &.{ "signed", "unsigned" }, &.{ 0, 1 });
|
||||
const Packed = @Union(.@"packed", Tag, &.{ "signed", "unsigned" }, &.{ i32, u32 }, &@splat(.{}));
|
||||
|
||||
export fn entry() void {
|
||||
const tagged: Packed = .{ .signed = -1 };
|
||||
_ = tagged;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:35: error: packed union does not support enum tag type
|
||||
|
|
@ -7,6 +7,5 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :2:35: error: 1 enum fields missing in union
|
||||
// :1:13: note: field 'arst' missing, declared here
|
||||
// :1:13: note: enum declared here
|
||||
// :2:16: error: enum field 'arst' missing from union
|
||||
// :1:36: note: enum field here
|
||||
|
|
|
|||
|
|
@ -7,7 +7,5 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :2:35: error: 2 enum fields missing in union
|
||||
// :1:13: note: field 'signed' missing, declared here
|
||||
// :1:13: note: field 'unsigned' missing, declared here
|
||||
// :1:13: note: enum declared here
|
||||
// :2:16: error: enum field 'signed' missing from union
|
||||
// :1:36: note: enum field here
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
const Untagged = @Union(.auto, null, &.{"foo"}, &.{opaque {}}, &.{.{}});
|
||||
const Opaque = opaque {};
|
||||
const Untagged = @Union(.auto, null, &.{"foo"}, &.{Opaque}, &.{.{}});
|
||||
export fn entry() usize {
|
||||
return @sizeOf(Untagged);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:49: error: opaque types have unknown size and therefore cannot be directly embedded in unions
|
||||
// :1:52: note: opaque declared here
|
||||
// :2:49: error: cannot directly embed opaque type 'tmp.Opaque' in union
|
||||
// :2:49: note: opaque types have unknown size
|
||||
// :1:16: note: opaque declared here
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ comptime {
|
|||
_ = @Union(.auto, null, &.{"foo"}, &.{usize}, &.{.{ .@"align" = 3 }});
|
||||
}
|
||||
comptime {
|
||||
_ = @Struct(.auto, null, &.{"a"}, &.{u32}, &.{.{ .@"comptime" = true, .@"align" = 5 }});
|
||||
_ = @Struct(.auto, null, &.{"a"}, &.{u32}, &.{.{
|
||||
.@"comptime" = true,
|
||||
.@"align" = 5,
|
||||
.default_value_ptr = &@as(u32, 0),
|
||||
}});
|
||||
}
|
||||
comptime {
|
||||
_ = @Pointer(.many, .{ .@"align" = 7 }, u8, null);
|
||||
|
|
@ -12,4 +16,4 @@ comptime {
|
|||
//
|
||||
// :2:51: error: alignment value '3' is not a power of two
|
||||
// :5:48: error: alignment value '5' is not a power of two
|
||||
// :8:26: error: alignment value '7' is not a power of two
|
||||
// :12:26: error: alignment value '7' is not a power of two
|
||||
|
|
|
|||
|
|
@ -12,5 +12,4 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :10:15: error: unable to resolve inferred error set of generic function
|
||||
// :1:1: note: generic function declared here
|
||||
// :1:1: error: cannot resolve inferred error set of generic function type 'fn (anytype) @typeInfo(@typeInfo(@TypeOf(tmp.foo)).@"fn".return_type.?).error_union.error_set!void'
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@ pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :5:54: error: pointer to comptime-only type '?*tmp.GuSettings' must be comptime-known, but operand is runtime-known
|
||||
// :2:10: note: struct requires comptime because of this field
|
||||
// :2:10: note: use '*const fn (c_int) callconv(.c) void' for a function pointer type
|
||||
// :6:19: error: cannot load comptime-only type '?fn (c_int) callconv(.c) void'
|
||||
// :6:20: note: pointer of type '*?fn (c_int) callconv(.c) void' is runtime-known
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
var rt: usize = 0;
|
||||
export fn foo() void {
|
||||
const x: [*]const type = &.{ u8, u16 };
|
||||
_ = &x[rt];
|
||||
_ = x[rt];
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:12: error: values of type '[*]const type' must be comptime-known, but index value is runtime-known
|
||||
// :4:11: note: types are not available at runtime
|
||||
// :4:11: error: values of type 'type' must be comptime-known, but index value is runtime-known
|
||||
// :4:10: note: types are not available at runtime
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :9:54: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known
|
||||
// :9:54: error: values of type 'builtin.Type.StructField' must be comptime-known, but index value is runtime-known
|
||||
// : note: struct requires comptime because of this field
|
||||
// : note: types are not available at runtime
|
||||
// : struct requires comptime because of this field
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ pub export fn entry3() void {
|
|||
}
|
||||
// error
|
||||
//
|
||||
// :7:10: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :7:10: error: values of type 'fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :7:10: note: use '*const fn () void' for a function pointer type
|
||||
// :15:18: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :15:18: error: values of type 'fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :15:17: note: use '*const fn () void' for a function pointer type
|
||||
// :22:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :22:19: error: values of type 'fn () void' must be comptime-known, but index value is runtime-known
|
||||
// :22:18: note: use '*const fn () void' for a function pointer type
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ var rt: u32 = undefined;
|
|||
//
|
||||
// :19:8: error: unable to evaluate comptime expression
|
||||
// :19:5: note: operation is runtime due to this operand
|
||||
// :6:8: note: called at comptime from here
|
||||
// :5:1: note: 'comptime' keyword forces comptime evaluation
|
||||
// :19:8: error: unable to evaluate comptime expression
|
||||
// :19:5: note: operation is runtime due to this operand
|
||||
// :14:8: note: called at comptime from here
|
||||
// :10:12: note: called at comptime from here
|
||||
// :10:12: note: call to function with comptime-only return type 'type' is evaluated at comptime
|
||||
// :13:10: note: return type declared here
|
||||
// :10:12: note: types are not available at runtime
|
||||
// :2:8: note: called inline here
|
||||
// :19:8: error: unable to evaluate comptime expression
|
||||
// :19:5: note: operation is runtime due to this operand
|
||||
// :6:8: note: called at comptime from here
|
||||
// :5:1: note: 'comptime' keyword forces comptime evaluation
|
||||
|
|
|
|||
|
|
@ -12,4 +12,3 @@ pub export fn entry() void {
|
|||
// :6:12: error: variable of type 'tmp.S' must be const or comptime
|
||||
// :2:8: note: struct requires comptime because of this field
|
||||
// :2:8: note: use '*const fn () void' for a function pointer type
|
||||
// :3:8: note: struct requires comptime because of this field
|
||||
|
|
|
|||
|
|
@ -12,4 +12,3 @@ pub export fn entry() void {
|
|||
// :6:12: error: variable of type 'tmp.U' must be const or comptime
|
||||
// :2:8: note: union requires comptime because of this field
|
||||
// :2:8: note: use '*const fn () void' for a function pointer type
|
||||
// :3:8: note: union requires comptime because of this field
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ export fn entry4() usize {
|
|||
// :5:20: error: no size available for comptime-only type 'comptime_int'
|
||||
// :8:20: error: no size available for uninstantiable type 'noreturn'
|
||||
// :12:20: error: no size available for comptime-only type 'tmp.S3'
|
||||
// :10:12: note: struct declared here
|
||||
// :16:20: error: no size available for uninstantiable type 'tmp.S4'
|
||||
// :14:12: note: struct declared here
|
||||
|
|
|
|||
|
|
@ -49,27 +49,27 @@ export fn align5() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :13:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U0'
|
||||
// :13:17: error: no size available for uninstantiable type 'tmp.U0'
|
||||
// :5:12: note: union declared here
|
||||
// :16:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U1'
|
||||
// :16:17: error: no size available for uninstantiable type 'tmp.U1'
|
||||
// :6:12: note: union declared here
|
||||
// :19:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U2'
|
||||
// :19:17: error: no size available for uninstantiable type 'tmp.U2'
|
||||
// :7:12: note: union declared here
|
||||
// :22:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U3'
|
||||
// :22:17: error: no size available for uninstantiable type 'tmp.U3'
|
||||
// :8:12: note: union declared here
|
||||
// :25:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U4'
|
||||
// :25:17: error: no size available for uninstantiable type 'tmp.U4'
|
||||
// :9:12: note: union declared here
|
||||
// :28:17: error: no size available for uninstantiable type 'sizeof_alignof_empty_union.U5'
|
||||
// :28:17: error: no size available for uninstantiable type 'tmp.U5'
|
||||
// :10:12: note: union declared here
|
||||
// :32:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U0'
|
||||
// :32:18: error: no align available for uninstantiable type 'tmp.U0'
|
||||
// :5:12: note: union declared here
|
||||
// :35:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U1'
|
||||
// :35:18: error: no align available for uninstantiable type 'tmp.U1'
|
||||
// :6:12: note: union declared here
|
||||
// :38:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U2'
|
||||
// :38:18: error: no align available for uninstantiable type 'tmp.U2'
|
||||
// :7:12: note: union declared here
|
||||
// :41:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U3'
|
||||
// :41:18: error: no align available for uninstantiable type 'tmp.U3'
|
||||
// :8:12: note: union declared here
|
||||
// :44:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U4'
|
||||
// :44:18: error: no align available for uninstantiable type 'tmp.U4'
|
||||
// :9:12: note: union declared here
|
||||
// :47:18: error: no align available for uninstantiable type 'sizeof_alignof_empty_union.U5'
|
||||
// :47:18: error: no align available for uninstantiable type 'tmp.U5'
|
||||
// :10:12: note: union declared here
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extern fn Text(str: []const u8, num: i32) callconv(.c) void;
|
||||
export fn entry() void {
|
||||
_ = Text;
|
||||
Text(undefined, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const Small = enum(u2) {
|
||||
One,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
one,
|
||||
two,
|
||||
three,
|
||||
four,
|
||||
five,
|
||||
};
|
||||
|
||||
const SmallUnion = union(enum(u2)) {
|
||||
|
|
@ -14,13 +14,13 @@ const SmallUnion = union(enum(u2)) {
|
|||
};
|
||||
|
||||
comptime {
|
||||
_ = Small;
|
||||
_ = Small.one;
|
||||
}
|
||||
comptime {
|
||||
_ = SmallUnion;
|
||||
_ = SmallUnion.one;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:5: error: enumeration value '4' too large for type 'u2'
|
||||
// :13:5: error: enumeration value '4' too large for type 'u2'
|
||||
// :6:5: error: enum tag value '4' too large for type 'u2'
|
||||
// :13:5: error: enum tag value '4' too large for type 'u2'
|
||||
|
|
|
|||
|
|
@ -21,22 +21,15 @@ export fn e() void {
|
|||
p.* = undefined;
|
||||
}
|
||||
|
||||
export fn f() void {
|
||||
const p: **comptime_int = @ptrFromInt(16); // double pointer ('*comptime_int' is comptime-only)
|
||||
p.* = undefined;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:9: error: cannot store comptime-only type 'fn () void' at runtime
|
||||
// :3:6: note: operation is runtime due to this pointer
|
||||
// :7:11: error: expected type 'anyopaque', found '@TypeOf(undefined)'
|
||||
// :7:11: note: cannot coerce to 'anyopaque'
|
||||
// :7:11: note: cannot coerce to uninstantiable type 'anyopaque'
|
||||
// :11:12: error: cannot load opaque type 'anyopaque'
|
||||
// :16:11: error: expected type 'tmp.Opaque', found '@TypeOf(undefined)'
|
||||
// :16:11: note: cannot coerce to 'tmp.Opaque'
|
||||
// :16:11: note: cannot coerce to uninstantiable type 'tmp.Opaque'
|
||||
// :14:16: note: opaque declared here
|
||||
// :21:9: error: cannot store comptime-only type 'comptime_int' at runtime
|
||||
// :21:6: note: operation is runtime due to this pointer
|
||||
// :26:9: error: cannot store comptime-only type '*comptime_int' at runtime
|
||||
// :26:6: note: operation is runtime due to this pointer
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ const A = struct {
|
|||
};
|
||||
|
||||
comptime {
|
||||
_ = A;
|
||||
_ = @as(A, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: struct 'tmp.A' depends on itself
|
||||
// :3:21: error: type 'tmp.A' depends on itself for size query here
|
||||
|
|
|
|||
|
|
@ -12,4 +12,7 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:17: error: struct 'tmp.LhsExpr' depends on itself
|
||||
// error: dependency loop with length 2
|
||||
// :2:14: note: type 'tmp.LhsExpr' depends on type 'tmp.AstObject' for field declared here
|
||||
// :5:14: note: type 'tmp.AstObject' depends on type 'tmp.LhsExpr' for field declared here
|
||||
// note: eliminate any one of these dependencies to break the loop
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
const S = struct {
|
||||
next: ?*align(1) S align(128),
|
||||
};
|
||||
|
||||
export fn entry() usize {
|
||||
return @alignOf(S);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: struct layout depends on being pointer aligned
|
||||
|
|
@ -8,4 +8,4 @@ pub export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :2:22: error: size of packed struct '131070' exceeds maximum bit width of 65535
|
||||
// :2:22: error: packed struct bit width '131070' exceeds maximum bit width of 65535
|
||||
|
|
|
|||
|
|
@ -7,4 +7,9 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:1: error: dependency loop detected
|
||||
// error: dependency loop with length 4
|
||||
// :1:23: note: value of declaration 'tmp.a' uses type of declaration 'tmp.a' here
|
||||
// :1:18: note: type of declaration 'tmp.a' uses value of declaration 'tmp.b' here
|
||||
// :2:23: note: value of declaration 'tmp.b' uses type of declaration 'tmp.b' here
|
||||
// :2:18: note: type of declaration 'tmp.b' uses value of declaration 'tmp.a' here
|
||||
// note: eliminate any one of these dependencies to break the loop
|
||||
|
|
|
|||
|
|
@ -16,22 +16,6 @@ pub export fn entry2() void {
|
|||
_ = b;
|
||||
}
|
||||
|
||||
const Int = @typeInfo(bar).@"struct".backing_integer.?;
|
||||
|
||||
const foo = enum(Int) {
|
||||
c = @bitCast(bar{
|
||||
.name = "test",
|
||||
}),
|
||||
};
|
||||
|
||||
const bar = packed struct {
|
||||
name: [*:0]const u8,
|
||||
};
|
||||
|
||||
pub export fn entry3() void {
|
||||
_ = @field(foo, "c");
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :7:13: error: unable to evaluate comptime expression
|
||||
|
|
@ -40,6 +24,3 @@ pub export fn entry3() void {
|
|||
// :13:13: error: unable to evaluate comptime expression
|
||||
// :13:16: note: operation is runtime due to this operand
|
||||
// :13:13: note: initializer of container-level variable must be comptime-known
|
||||
// :22:9: error: unable to evaluate comptime expression
|
||||
// :22:21: note: operation is runtime due to this operand
|
||||
// :21:13: note: enum field values must be comptime-known
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -12,5 +12,5 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :6:9: error: enum tag value 60 already taken
|
||||
// :4:9: note: other occurrence here
|
||||
// :6:9: error: enum tag value '60' for field 'E' already taken
|
||||
// :4:9: note: previous occurrence in field 'C'
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
const U = union {
|
||||
next: ?*align(1) U align(128),
|
||||
};
|
||||
|
||||
export fn entry() usize {
|
||||
return @alignOf(U);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:11: error: union layout depends on being pointer aligned
|
||||
|
|
@ -15,6 +15,5 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :7:11: error: enum field(s) missing in union
|
||||
// :4:5: note: field 'c' missing, declared here
|
||||
// :1:11: note: enum declared here
|
||||
// :7:11: error: enum field 'c' missing from union
|
||||
// :4:5: note: enum field here
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :4:5: error: union field 'b' ordered differently than corresponding enum field
|
||||
// :1:23: note: enum field here
|
||||
// :14:5: error: union field 'b' ordered differently than corresponding enum field
|
||||
// :10:5: note: enum field here
|
||||
// :3:15: error: union field order does not match tag enum field order
|
||||
// :5:5: note: union field 'a' is index 1
|
||||
// :1:20: note: enum field 'a' is index 0
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ pub export fn entry2() void {
|
|||
const U = union(enum) {
|
||||
a: noreturn,
|
||||
};
|
||||
var u: U = undefined;
|
||||
u = .a;
|
||||
const u: U = .a;
|
||||
_ = u;
|
||||
}
|
||||
pub export fn entry3() void {
|
||||
const U = union(enum) {
|
||||
|
|
@ -30,12 +30,12 @@ pub export fn entry3() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :11:14: error: cannot initialize 'noreturn' field of union
|
||||
// :11:14: error: cannot initialize union field with uninstantiable type 'noreturn'
|
||||
// :4:9: note: field 'b' declared here
|
||||
// :2:15: note: union declared here
|
||||
// :19:10: error: cannot initialize 'noreturn' field of union
|
||||
// :18:19: error: cannot initialize union field with uninstantiable type 'noreturn'
|
||||
// :16:9: note: field 'a' declared here
|
||||
// :15:15: note: union declared here
|
||||
// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).@"union".tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
|
||||
// :23:9: note: 'noreturn' field here
|
||||
// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).@"union".tag_type.?' to union 'tmp.entry3.U' which has non-void fields
|
||||
// :23:9: note: field 'a' has uninstantiable type 'noreturn'
|
||||
// :22:15: note: union declared here
|
||||
|
|
|
|||
|
|
@ -13,6 +13,5 @@ export fn entry() usize {
|
|||
|
||||
// error
|
||||
//
|
||||
// :6:17: error: enum field(s) missing in union
|
||||
// :4:5: note: field 'C' missing, declared here
|
||||
// :1:16: note: enum declared here
|
||||
// :6:17: error: enum field 'C' missing from union
|
||||
// :4:5: note: enum field here
|
||||
|
|
|
|||
|
|
@ -10,5 +10,4 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:22: error: specified integer tag type cannot represent every field
|
||||
// :1:22: note: type 'i2' cannot fit values in range 0...3
|
||||
// :4:5: error: enum tag value '2' too large for type 'i2'
|
||||
|
|
|
|||
|
|
@ -11,5 +11,4 @@ export fn entry() void {
|
|||
|
||||
// error
|
||||
//
|
||||
// :1:22: error: specified integer tag type cannot represent every field
|
||||
// :1:22: note: type 'u2' cannot fit values in range 0...4
|
||||
// :6:5: error: enum tag value '4' too large for type 'u2'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const UntaggedUnion = union {};
|
||||
const UntaggedUnion = union { a: void };
|
||||
comptime {
|
||||
@intFromEnum(@as(UntaggedUnion, undefined));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ pub export fn entry3() void {
|
|||
// :14:24: error: cannot pass 'u48' to variadic function
|
||||
// :14:24: note: only integers with 0 or power of two bits are extern compatible
|
||||
// :18:24: error: cannot pass 'void' to variadic function
|
||||
// :18:24: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
|
||||
// :18:24: note: 'void' is a zero bit type
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
comptime {
|
||||
_ = enum(i0) { a, _ };
|
||||
const E = enum(i0) { a, _ };
|
||||
_ = @as(E, undefined);
|
||||
}
|
||||
|
||||
comptime {
|
||||
_ = enum(u0) { a, _ };
|
||||
const E = enum(u0) { a, _ };
|
||||
_ = @as(E, undefined);
|
||||
}
|
||||
|
||||
comptime {
|
||||
_ = enum(u0) { a, b, _ };
|
||||
const E = enum(u0) { a, b, _ };
|
||||
_ = @as(E, undefined);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:9: error: non-exhaustive enum specifies every value
|
||||
// :6:9: error: non-exhaustive enum specifies every value
|
||||
// :10:23: error: enumeration value '1' too large for type 'u0'
|
||||
// :2:15: error: non-exhaustive enum specifies every value
|
||||
// :7:15: error: non-exhaustive enum specifies every value
|
||||
// :12:29: error: enum tag value '1' too large for type 'u0'
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ comptime {
|
|||
}
|
||||
const std = @import("std");
|
||||
const io = std.Io.Threaded.global_single_threaded.ioBasic();
|
||||
#expect_error=main.zig:7:5: error: enumeration value '4' too large for type 'u2'
|
||||
#expect_error=main.zig:7:5: error: enum tag value '4' too large for type 'u2'
|
||||
#update=increase tag size
|
||||
#file=main.zig
|
||||
const Tag = u3;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue