| ... | ... | @@ -1905,8 +1905,12 @@ fn analyzeBodyInner( |
| 1905 | 1905 | const err_union = try sema.resolveInst(extra.data.operand); |
| 1906 | 1906 | const err_union_ty = sema.typeOf(err_union); |
| 1907 | 1907 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 1908 | | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ |
| 1909 | | err_union_ty.fmt(pt), |
| 1908 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 1909 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); |
| 1910 | errdefer msg.destroy(sema.gpa); |
| 1911 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 1912 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| 1913 | break :msg msg; |
| 1910 | 1914 | }); |
| 1911 | 1915 | } |
| 1912 | 1916 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| ... | ... | @@ -18175,8 +18179,12 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 18175 | 18179 | const pt = sema.pt; |
| 18176 | 18180 | const zcu = pt.zcu; |
| 18177 | 18181 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 18178 | | return sema.fail(parent_block, operand_src, "expected error union type, found '{f}'", .{ |
| 18179 | | err_union_ty.fmt(pt), |
| 18182 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 18183 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); |
| 18184 | errdefer msg.destroy(sema.gpa); |
| 18185 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 18186 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| 18187 | break :msg msg; |
| 18180 | 18188 | }); |
| 18181 | 18189 | } |
| 18182 | 18190 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |
| ... | ... | @@ -18235,8 +18243,12 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 18235 | 18243 | const pt = sema.pt; |
| 18236 | 18244 | const zcu = pt.zcu; |
| 18237 | 18245 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 18238 | | return sema.fail(parent_block, operand_src, "expected error union type, found '{f}'", .{ |
| 18239 | | err_union_ty.fmt(pt), |
| 18246 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 18247 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); |
| 18248 | errdefer msg.destroy(sema.gpa); |
| 18249 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 18250 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| 18251 | break :msg msg; |
| 18240 | 18252 | }); |
| 18241 | 18253 | } |
| 18242 | 18254 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |