mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
parent
bbb565a21e
commit
0ccc186869
@ -3753,13 +3753,13 @@ static bool is_container(TypeTableEntry *type_entry) {
|
||||
}
|
||||
|
||||
bool is_container_ref(TypeTableEntry *type_entry) {
|
||||
return (type_entry->id == TypeTableEntryIdPointer) ?
|
||||
return (type_entry->id == TypeTableEntryIdPointer && type_entry->data.pointer.ptr_len == PtrLenSingle) ?
|
||||
is_container(type_entry->data.pointer.child_type) : is_container(type_entry);
|
||||
}
|
||||
|
||||
TypeTableEntry *container_ref_type(TypeTableEntry *type_entry) {
|
||||
assert(is_container_ref(type_entry));
|
||||
return (type_entry->id == TypeTableEntryIdPointer) ?
|
||||
return (type_entry->id == TypeTableEntryIdPointer && type_entry->data.pointer.ptr_len == PtrLenSingle) ?
|
||||
type_entry->data.pointer.child_type : type_entry;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"field access of unknown length pointer",
|
||||
\\const Foo = extern struct {
|
||||
\\ a: i32,
|
||||
\\};
|
||||
\\
|
||||
\\export fn entry(foo: [*]Foo) void {
|
||||
\\ foo.a += 1;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:6:8: error: type '[*]Foo' does not support field access",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"unknown length pointer to opaque",
|
||||
\\export const T = [*]@OpaqueType();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user