Update zig files for opaque type syntax
This commit is contained in:
@@ -180,7 +180,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ .layout = .Auto,
|
||||
\\ .tag_type = null,
|
||||
\\ .fields = &[_]TypeInfo.UnionField{
|
||||
\\ .{ .name = "foo", .field_type = @Type(.Opaque), .alignment = 1 },
|
||||
\\ .{ .name = "foo", .field_type = opaque {}, .alignment = 1 },
|
||||
\\ },
|
||||
\\ .decls = &[_]TypeInfo.Declaration{},
|
||||
\\ },
|
||||
@@ -2613,7 +2613,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("directly embedding opaque type in struct and union",
|
||||
\\const O = @Type(.Opaque);
|
||||
\\const O = opaque {};
|
||||
\\const Foo = struct {
|
||||
\\ o: O,
|
||||
\\};
|
||||
@@ -2628,7 +2628,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var bar: Bar = undefined;
|
||||
\\}
|
||||
\\export fn c() void {
|
||||
\\ var baz: *@Type(.Opaque) = undefined;
|
||||
\\ var baz: *opaque {} = undefined;
|
||||
\\ const qux = .{baz.*};
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
@@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("unknown length pointer to opaque",
|
||||
\\export const T = [*]@Type(.Opaque);
|
||||
\\export const T = [*]opaque {};
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:1:21: error: unknown-length pointer to opaque",
|
||||
});
|
||||
@@ -6827,8 +6827,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:2:31: error: index 2 outside array of size 2",
|
||||
});
|
||||
|
||||
cases.add("wrong pointer coerced to pointer to @Type(.Opaque)",
|
||||
\\const Derp = @Type(.Opaque);
|
||||
cases.add("wrong pointer coerced to pointer to opaque {}",
|
||||
\\const Derp = opaque {};
|
||||
\\extern fn bar(d: *Derp) void;
|
||||
\\export fn foo() void {
|
||||
\\ var x = @as(u8, 1);
|
||||
@@ -6854,8 +6854,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\export fn entry5() void {
|
||||
\\ var d = null;
|
||||
\\}
|
||||
\\export fn entry6(opaque: *Opaque) void {
|
||||
\\ var e = opaque.*;
|
||||
\\export fn entry6(opaque_: *Opaque) void {
|
||||
\\ var e = opaque_.*;
|
||||
\\}
|
||||
\\export fn entry7() void {
|
||||
\\ var f = i32;
|
||||
@@ -6866,7 +6866,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\export fn entry9() void {
|
||||
\\ var z: noreturn = return;
|
||||
\\}
|
||||
\\const Opaque = @Type(.Opaque);
|
||||
\\const Opaque = opaque {};
|
||||
\\const Foo = struct {
|
||||
\\ fn bar(self: *const Foo) void {}
|
||||
\\};
|
||||
@@ -7020,7 +7020,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("field access of opaque type",
|
||||
\\const MyType = @Type(.Opaque);
|
||||
\\const MyType = opaque {};
|
||||
\\
|
||||
\\export fn entry() bool {
|
||||
\\ var x: i32 = 1;
|
||||
@@ -7623,7 +7623,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("function returning opaque type",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\export fn bar() !FooType {
|
||||
\\ return error.InvalidValue;
|
||||
\\}
|
||||
@@ -7641,7 +7641,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("generic function returning opaque type",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\fn generic(comptime T: type) !T {
|
||||
\\ return undefined;
|
||||
\\}
|
||||
@@ -7665,7 +7665,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("function parameter is opaque",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\export fn entry1() void {
|
||||
\\ const someFuncPtr: fn (FooType) void = undefined;
|
||||
\\}
|
||||
|
||||
Reference in New Issue
Block a user