| ... | @@ -1905,8 +1905,12 @@ fn analyzeBodyInner( | ... | @@ -1905,8 +1905,12 @@ fn analyzeBodyInner( |
| 1905 | const err_union = try sema.resolveInst(extra.data.operand); | 1905 | const err_union = try sema.resolveInst(extra.data.operand); |
| 1906 | const err_union_ty = sema.typeOf(err_union); | 1906 | const err_union_ty = sema.typeOf(err_union); |
| 1907 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 1907 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 1908 | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ | 1908 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 1909 | err_union_ty.fmt(pt), | 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 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); | 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,8 +18179,12 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 18175 | const pt = sema.pt; | 18179 | const pt = sema.pt; |
| 18176 | const zcu = pt.zcu; | 18180 | const zcu = pt.zcu; |
| 18177 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 18181 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 18178 | return sema.fail(parent_block, operand_src, "expected error union type, found '{f}'", .{ | 18182 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 18179 | err_union_ty.fmt(pt), | 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 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); | 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,8 +18243,12 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 18235 | const pt = sema.pt; | 18243 | const pt = sema.pt; |
| 18236 | const zcu = pt.zcu; | 18244 | const zcu = pt.zcu; |
| 18237 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 18245 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 18238 | return sema.fail(parent_block, operand_src, "expected error union type, found '{f}'", .{ | 18246 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 18239 | err_union_ty.fmt(pt), | 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 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); | 18254 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |