| ... | ... | @@ -23605,10 +23605,13 @@ fn fieldCallBind( |
| 23605 | 23605 | } |
| 23606 | 23606 | |
| 23607 | 23607 | // If we get here, we need to look for a decl in the struct type instead. |
| 23608 | | switch (concrete_ty.zigTypeTag()) { |
| 23609 | | .Struct, .Opaque, .Union, .Enum => { |
| 23608 | const found_decl = switch (concrete_ty.zigTypeTag()) { |
| 23609 | .Struct, .Opaque, .Union, .Enum => found_decl: { |
| 23610 | 23610 | if (concrete_ty.getNamespace()) |namespace| { |
| 23611 | | if (try sema.namespaceLookupRef(block, src, namespace, field_name)) |inst| { |
| 23611 | if (try sema.namespaceLookup(block, src, namespace, field_name)) |decl_idx| { |
| 23612 | try sema.addReferencedBy(block, src, decl_idx); |
| 23613 | const inst = try sema.analyzeDeclRef(decl_idx); |
| 23614 | |
| 23612 | 23615 | const decl_val = try sema.analyzeLoad(block, src, inst, src); |
| 23613 | 23616 | const decl_type = sema.typeOf(decl_val); |
| 23614 | 23617 | if (decl_type.zigTypeTag() == .Fn and |
| ... | ... | @@ -23625,7 +23628,7 @@ fn fieldCallBind( |
| 23625 | 23628 | first_param_type.ptrSize() == .C) and |
| 23626 | 23629 | first_param_type.childType().eql(concrete_ty, sema.mod))) |
| 23627 | 23630 | { |
| 23628 | | // zig fmt: on |
| 23631 | // zig fmt: on |
| 23629 | 23632 | // TODO: bound fn calls on rvalues should probably |
| 23630 | 23633 | // generate a by-value argument somehow. |
| 23631 | 23634 | const ty = Type.Tag.bound_fn.init(); |
| ... | ... | @@ -23664,16 +23667,22 @@ fn fieldCallBind( |
| 23664 | 23667 | return sema.addConstant(ty, value); |
| 23665 | 23668 | } |
| 23666 | 23669 | } |
| 23670 | break :found_decl decl_idx; |
| 23667 | 23671 | } |
| 23668 | 23672 | } |
| 23673 | break :found_decl null; |
| 23669 | 23674 | }, |
| 23670 | | else => {}, |
| 23671 | | } |
| 23675 | else => null, |
| 23676 | }; |
| 23672 | 23677 | |
| 23673 | 23678 | const msg = msg: { |
| 23674 | 23679 | const msg = try sema.errMsg(block, src, "no field or member function named '{s}' in '{}'", .{ field_name, concrete_ty.fmt(sema.mod) }); |
| 23675 | 23680 | errdefer msg.destroy(sema.gpa); |
| 23676 | 23681 | try sema.addDeclaredHereNote(msg, concrete_ty); |
| 23682 | if (found_decl) |decl_idx| { |
| 23683 | const decl = sema.mod.declPtr(decl_idx); |
| 23684 | try sema.mod.errNoteNonLazy(decl.srcLoc(), msg, "'{s}' is not a member function", .{field_name}); |
| 23685 | } |
| 23677 | 23686 | break :msg msg; |
| 23678 | 23687 | }; |
| 23679 | 23688 | return sema.failWithOwnedErrorMsg(msg); |