mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Update compile error test for field access of opaque type
This commit is contained in:
parent
6b8ae6fffb
commit
bf4bfe54ac
@ -22387,6 +22387,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira,
|
||||
prefix_name = "enum ";
|
||||
} else if (bare_struct_type->id == ZigTypeIdUnion) {
|
||||
prefix_name = "union ";
|
||||
} else if (bare_struct_type->id == ZigTypeIdOpaque) {
|
||||
prefix_name = "opaque type ";
|
||||
} else {
|
||||
prefix_name = "";
|
||||
}
|
||||
|
||||
@ -126,6 +126,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:27:24: note: referenced here",
|
||||
});
|
||||
|
||||
cases.add("field access of opaque type",
|
||||
\\const MyType = opaque {};
|
||||
\\
|
||||
\\export fn entry() bool {
|
||||
\\ var x: i32 = 1;
|
||||
\\ return bar(@ptrCast(*MyType, &x));
|
||||
\\}
|
||||
\\
|
||||
\\fn bar(x: *MyType) bool {
|
||||
\\ return x.blah;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:9:13: error: no member named 'blah' in opaque type 'MyType'",
|
||||
});
|
||||
|
||||
cases.add("opaque type with field",
|
||||
\\const Opaque = opaque { foo: i32 };
|
||||
\\export fn entry() void {
|
||||
@ -7029,21 +7044,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:37:29: error: cannot store runtime value in compile time variable",
|
||||
});
|
||||
|
||||
cases.add("field access of opaque type",
|
||||
\\const MyType = opaque {};
|
||||
\\
|
||||
\\export fn entry() bool {
|
||||
\\ var x: i32 = 1;
|
||||
\\ return bar(@ptrCast(*MyType, &x));
|
||||
\\}
|
||||
\\
|
||||
\\fn bar(x: *MyType) bool {
|
||||
\\ return x.blah;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:9:13: error: type '*MyType' does not support field access",
|
||||
});
|
||||
|
||||
cases.add("invalid legacy unicode escape",
|
||||
\\export fn entry() void {
|
||||
\\ const a = '\U1234';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user