| ... | ... | @@ -1330,7 +1330,8 @@ fn analyzeBodyInner( |
| 1330 | 1330 | const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index); |
| 1331 | 1331 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1332 | 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 | 1335 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1335 | 1336 | if (is_non_err_tv.val.toBool()) { |
| 1336 | 1337 | const err_union_ty = sema.typeOf(err_union); |
| ... | ... | @@ -1357,7 +1358,8 @@ fn analyzeBodyInner( |
| 1357 | 1358 | // try sema.analyzeLoad(block, src, operand, operand_src) |
| 1358 | 1359 | // else |
| 1359 | 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 | 1363 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1362 | 1364 | // if (is_non_err_tv.val.toBool()) { |
| 1363 | 1365 | // if (is_ptr) { |
| ... | ... | @@ -1384,7 +1386,8 @@ fn analyzeBodyInner( |
| 1384 | 1386 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1385 | 1387 | const operand = try sema.resolveInst(extra.data.operand); |
| 1386 | 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 | 1391 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1389 | 1392 | if (is_non_err_tv.val.toBool()) { |
| 1390 | 1393 | break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); |
| ... | ... | @@ -1405,7 +1408,8 @@ fn analyzeBodyInner( |
| 1405 | 1408 | // const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1406 | 1409 | // const operand = try sema.resolveInst(extra.data.operand); |
| 1407 | 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 | 1413 | // const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1410 | 1414 | // if (is_non_err_tv.val.toBool()) { |
| 1411 | 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 | 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); |
| 13082 | | |
| 13083 | | if (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)) |is_non_err_val| { |
| 13085 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |
| 13086 | if (is_non_err != .none) { |
| 13087 | const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?; |
| 13084 | 13088 | if (is_non_err_val.toBool()) { |
| 13085 | 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 | 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); |
| 13128 | | |
| 13129 | | if (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)) |is_non_err_val| { |
| 13131 | const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union); |
| 13132 | if (is_non_err != .none) { |
| 13133 | const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?; |
| 13130 | 13134 | if (is_non_err_val.toBool()) { |
| 13131 | 13135 | return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false); |
| 13132 | 13136 | } |
| ... | ... | @@ -21795,7 +21799,7 @@ fn analyzeIsNull( |
| 21795 | 21799 | return block.addUnOp(air_tag, operand); |
| 21796 | 21800 | } |
| 21797 | 21801 | |
| 21798 | | fn analyzeIsNonErr( |
| 21802 | fn analyzeIsNonErrComptimeOnly( |
| 21799 | 21803 | sema: *Sema, |
| 21800 | 21804 | block: *Block, |
| 21801 | 21805 | src: LazySrcLoc, |
| ... | ... | @@ -21847,8 +21851,22 @@ fn analyzeIsNonErr( |
| 21847 | 21851 | return Air.Inst.Ref.bool_false; |
| 21848 | 21852 | } |
| 21849 | 21853 | } |
| 21850 | | try sema.requireRuntimeBlock(block, src); |
| 21851 | | return block.addUnOp(.is_non_err, operand); |
| 21854 | return Air.Inst.Ref.none; |
| 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 | 21872 | fn analyzeSlice( |