| ... | @@ -1330,7 +1330,8 @@ fn analyzeBodyInner( | ... | @@ -1330,7 +1330,8 @@ fn analyzeBodyInner( |
| 1330 | const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index); | 1330 | const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index); |
| 1331 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 1331 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1332 | const err_union = try sema.resolveInst(extra.data.operand); | 1332 | const err_union = try sema.resolveInst(extra.data.operand); |
| 1333 | const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); | 1333 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| | 1334 | assert(is_non_err != .none); |
| 1334 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); | 1335 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1335 | if (is_non_err_tv.val.toBool()) { | 1336 | if (is_non_err_tv.val.toBool()) { |
| 1336 | const err_union_ty = sema.typeOf(err_union); | 1337 | const err_union_ty = sema.typeOf(err_union); |
| ... | @@ -1357,7 +1358,8 @@ fn analyzeBodyInner( | ... | @@ -1357,7 +1358,8 @@ fn analyzeBodyInner( |
| 1357 | // try sema.analyzeLoad(block, src, operand, operand_src) | 1358 | // try sema.analyzeLoad(block, src, operand, operand_src) |
| 1358 | // else | 1359 | // else |
| 1359 | // operand; | 1360 | // operand; |
| 1360 | // const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); | 1361 | // const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| | 1362 | // assert(is_non_err != .none); |
| 1361 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); | 1363 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1362 | // if (is_non_err_tv.val.toBool()) { | 1364 | // if (is_non_err_tv.val.toBool()) { |
| 1363 | // if (is_ptr) { | 1365 | // if (is_ptr) { |
| ... | @@ -1384,7 +1386,8 @@ fn analyzeBodyInner( | ... | @@ -1384,7 +1386,8 @@ fn analyzeBodyInner( |
| 1384 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 1386 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1385 | const operand = try sema.resolveInst(extra.data.operand); | 1387 | const operand = try sema.resolveInst(extra.data.operand); |
| 1386 | const err_union = try sema.analyzeLoad(block, src, operand, operand_src); | 1388 | const err_union = try sema.analyzeLoad(block, src, operand, operand_src); |
| 1387 | const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); | 1389 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| | 1390 | assert(is_non_err != .none); |
| 1388 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); | 1391 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1389 | if (is_non_err_tv.val.toBool()) { | 1392 | if (is_non_err_tv.val.toBool()) { |
| 1390 | break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); | 1393 | break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); |
| ... | @@ -1405,7 +1408,8 @@ fn analyzeBodyInner( | ... | @@ -1405,7 +1408,8 @@ fn analyzeBodyInner( |
| 1405 | // const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 1408 | // const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1406 | // const operand = try sema.resolveInst(extra.data.operand); | 1409 | // const operand = try sema.resolveInst(extra.data.operand); |
| 1407 | // const err_union = try sema.analyzeLoad(block, src, operand, operand_src); | 1410 | // const err_union = try sema.analyzeLoad(block, src, operand, operand_src); |
| 1408 | // const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); | 1411 | // const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union); |
| | 1412 | // assert(is_non_err != .none); |
| 1409 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); | 1413 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1410 | // if (is_non_err_tv.val.toBool()) { | 1414 | // if (is_non_err_tv.val.toBool()) { |
| 1411 | // break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); | 1415 | // break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); |
| ... | @@ -13078,9 +13082,9 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -13078,9 +13082,9 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 13078 | err_union_ty.fmt(sema.mod), | 13082 | err_union_ty.fmt(sema.mod), |
| 13079 | }); | 13083 | }); |
| 13080 | } | 13084 | } |
| 13081 | const is_non_err = try sema.analyzeIsNonErr(parent_block, operand_src, err_union); | 13085 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |
| 13082 | | 13086 | if (is_non_err != .none) { |
| 13083 | if (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)) |is_non_err_val| { | 13087 | const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?; |
| 13084 | if (is_non_err_val.toBool()) { | 13088 | if (is_non_err_val.toBool()) { |
| 13085 | return sema.analyzeErrUnionPayload(parent_block, src, err_union_ty, err_union, operand_src, false); | 13089 | return sema.analyzeErrUnionPayload(parent_block, src, err_union_ty, err_union, operand_src, false); |
| 13086 | } | 13090 | } |
| ... | @@ -13124,9 +13128,9 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -13124,9 +13128,9 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 13124 | err_union_ty.fmt(sema.mod), | 13128 | err_union_ty.fmt(sema.mod), |
| 13125 | }); | 13129 | }); |
| 13126 | } | 13130 | } |
| 13127 | const is_non_err = try sema.analyzeIsNonErr(parent_block, operand_src, err_union); | 13131 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |
| 13128 | | 13132 | if (is_non_err != .none) { |
| 13129 | if (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)) |is_non_err_val| { | 13133 | const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?; |
| 13130 | if (is_non_err_val.toBool()) { | 13134 | if (is_non_err_val.toBool()) { |
| 13131 | return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false); | 13135 | return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false); |
| 13132 | } | 13136 | } |
| ... | @@ -21795,7 +21799,7 @@ fn analyzeIsNull( | ... | @@ -21795,7 +21799,7 @@ fn analyzeIsNull( |
| 21795 | return block.addUnOp(air_tag, operand); | 21799 | return block.addUnOp(air_tag, operand); |
| 21796 | } | 21800 | } |
| 21797 | | 21801 | |
| 21798 | fn analyzeIsNonErr( | 21802 | fn analyzeIsNonErrComptimeOnly( |
| 21799 | sema: *Sema, | 21803 | sema: *Sema, |
| 21800 | block: *Block, | 21804 | block: *Block, |
| 21801 | src: LazySrcLoc, | 21805 | src: LazySrcLoc, |
| ... | @@ -21847,8 +21851,22 @@ fn analyzeIsNonErr( | ... | @@ -21847,8 +21851,22 @@ fn analyzeIsNonErr( |
| 21847 | return Air.Inst.Ref.bool_false; | 21851 | return Air.Inst.Ref.bool_false; |
| 21848 | } | 21852 | } |
| 21849 | } | 21853 | } |
| 21850 | try sema.requireRuntimeBlock(block, src); | 21854 | return Air.Inst.Ref.none; |
| 21851 | return block.addUnOp(.is_non_err, operand); | 21855 | } |
| | 21856 | |
| | 21857 | fn analyzeIsNonErr( |
| | 21858 | sema: *Sema, |
| | 21859 | block: *Block, |
| | 21860 | src: LazySrcLoc, |
| | 21861 | operand: Air.Inst.Ref, |
| | 21862 | ) CompileError!Air.Inst.Ref { |
| | 21863 | const result = try sema.analyzeIsNonErrComptimeOnly(block, src, operand); |
| | 21864 | if (result == .none) { |
| | 21865 | try sema.requireRuntimeBlock(block, src); |
| | 21866 | return block.addUnOp(.is_non_err, operand); |
| | 21867 | } else { |
| | 21868 | return result; |
| | 21869 | } |
| 21852 | } | 21870 | } |
| 21853 | | 21871 | |
| 21854 | fn analyzeSlice( | 21872 | fn analyzeSlice( |