| ... | ... | @@ -1324,10 +1324,66 @@ fn analyzeBodyInner( |
| 1324 | 1324 | }, |
| 1325 | 1325 | .@"try" => blk: { |
| 1326 | 1326 | if (!block.is_comptime) break :blk try sema.zirTry(block, inst); |
| 1327 | | @panic("TODO"); |
| 1327 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1328 | const src = inst_data.src(); |
| 1329 | const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 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]; |
| 1332 | const operand = try sema.resolveInst(extra.data.operand); |
| 1333 | const operand_ty = sema.typeOf(operand); |
| 1334 | const is_ptr = operand_ty.zigTypeTag() == .Pointer; |
| 1335 | const err_union = if (is_ptr) |
| 1336 | try sema.analyzeLoad(block, src, operand, operand_src) |
| 1337 | else |
| 1338 | operand; |
| 1339 | const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); |
| 1340 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1341 | if (is_non_err_tv.val.toBool()) { |
| 1342 | if (is_ptr) { |
| 1343 | break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); |
| 1344 | } else { |
| 1345 | const err_union_ty = sema.typeOf(err_union); |
| 1346 | break :blk try sema.analyzeErrUnionPayload(block, src, err_union_ty, operand, operand_src, false); |
| 1347 | } |
| 1348 | } |
| 1349 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1350 | break always_noreturn; |
| 1351 | if (inst == break_data.block_inst) { |
| 1352 | break :blk try sema.resolveInst(break_data.operand); |
| 1353 | } else { |
| 1354 | break break_data.inst; |
| 1355 | } |
| 1328 | 1356 | }, |
| 1329 | | .try_inline => { |
| 1330 | | @panic("TODO"); |
| 1357 | .try_inline => blk: { |
| 1358 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1359 | const src = inst_data.src(); |
| 1360 | const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 1361 | const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index); |
| 1362 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1363 | const operand = try sema.resolveInst(extra.data.operand); |
| 1364 | const operand_ty = sema.typeOf(operand); |
| 1365 | const is_ptr = operand_ty.zigTypeTag() == .Pointer; |
| 1366 | const err_union = if (is_ptr) |
| 1367 | try sema.analyzeLoad(block, src, operand, operand_src) |
| 1368 | else |
| 1369 | operand; |
| 1370 | const is_non_err = try sema.analyzeIsNonErr(block, operand_src, err_union); |
| 1371 | const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err); |
| 1372 | if (is_non_err_tv.val.toBool()) { |
| 1373 | if (is_ptr) { |
| 1374 | break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false); |
| 1375 | } else { |
| 1376 | const err_union_ty = sema.typeOf(err_union); |
| 1377 | break :blk try sema.analyzeErrUnionPayload(block, src, err_union_ty, operand, operand_src, false); |
| 1378 | } |
| 1379 | } |
| 1380 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1381 | break always_noreturn; |
| 1382 | if (inst == break_data.block_inst) { |
| 1383 | break :blk try sema.resolveInst(break_data.operand); |
| 1384 | } else { |
| 1385 | break break_data.inst; |
| 1386 | } |
| 1331 | 1387 | }, |
| 1332 | 1388 | }; |
| 1333 | 1389 | if (sema.typeOf(air_inst).isNoReturn()) |