diff options
| author | Wooster <wooster0@proton.me> | 2023-07-30 11:10:41 +0200 |
|---|---|---|
| committer | wooster0 <wooster0@proton.me> | 2024-05-14 01:13:49 +0900 |
| commit | f14cf13ff8553030c47748a0cbd455514cd1f4a3 (patch) | |
| tree | 3bc7dbe10a781f500800a45569fb5786baef6c54 /src | |
| parent | 9ae43567a3ef14a815482ccaa2a5b412a716743e (diff) | |
| download | zig-f14cf13ff8553030c47748a0cbd455514cd1f4a3.tar.gz zig-f14cf13ff8553030c47748a0cbd455514cd1f4a3.zip | |
Sema: suggest using try/catch/if on method call on error union
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index c55531d924..a5c5f37e4c 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -27888,6 +27888,9 @@ fn fieldCallBind( const decl = mod.declPtr(decl_idx); try mod.errNoteNonLazy(decl.srcLoc(mod), msg, "'{}' is not a member function", .{field_name.fmt(ip)}); } + if (concrete_ty.zigTypeTag(mod) == .ErrorUnion) { + try sema.errNote(block, src, msg, "consider using 'try', 'catch', or 'if'", .{}); + } break :msg msg; }; return sema.failWithOwnedErrorMsg(block, msg); |
