mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
fix: Add error notes for method calls on double pointers (#20686)
This commit is contained in:
parent
93c546c8c9
commit
9b292c0949
@ -28023,6 +28023,10 @@ fn fieldCallBind(
|
||||
if (concrete_ty.zigTypeTag(mod) == .ErrorUnion) {
|
||||
try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{});
|
||||
}
|
||||
if (is_double_ptr) {
|
||||
try sema.errNote(src, msg, "method invocation only supports up to one level of implicit pointer dereferencing", .{});
|
||||
try sema.errNote(src, msg, "use '.*' to dereference pointer", .{});
|
||||
}
|
||||
break :msg msg;
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(block, msg);
|
||||
|
||||
15
test/cases/compile_errors/call_from_double_ptr.zig
Normal file
15
test/cases/compile_errors/call_from_double_ptr.zig
Normal file
@ -0,0 +1,15 @@
|
||||
const S = struct {
|
||||
fn b() void {}
|
||||
};
|
||||
|
||||
export fn entry(a: **S) void {
|
||||
_ = a.b();
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// 6:10: error: no field or member function named 'b' in '*tmp.S'
|
||||
// 6:10: note: method invocation only supports up to one level of implicit pointer dereferencing
|
||||
// 6:10: note: use '.*' to dereference pointer
|
||||
Loading…
x
Reference in New Issue
Block a user