| ... | ... | @@ -281,6 +281,15 @@ pub const ResultLoc = union(enum) { |
| 281 | 281 | }, |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | |
| 285 | /// Turns a `coerced_ty` back into a `ty`. Should be called at branch points |
| 286 | /// such as if and switch expressions. |
| 287 | fn br(rl: ResultLoc) ResultLoc { |
| 288 | return switch (rl) { |
| 289 | .coerced_ty => |ty| .{ .ty = ty }, |
| 290 | else => rl, |
| 291 | }; |
| 292 | } |
| 284 | 293 | }; |
| 285 | 294 | |
| 286 | 295 | pub const align_rl: ResultLoc = .{ .ty = .u16_type }; |
| ... | ... | @@ -748,15 +757,15 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 748 | 757 | .field_access => return fieldAccess(gz, scope, rl, node), |
| 749 | 758 | .float_literal => return floatLiteral(gz, rl, node), |
| 750 | 759 | |
| 751 | | .if_simple => return ifExpr(gz, scope, rl, node, tree.ifSimple(node)), |
| 752 | | .@"if" => return ifExpr(gz, scope, rl, node, tree.ifFull(node)), |
| 760 | .if_simple => return ifExpr(gz, scope, rl.br(), node, tree.ifSimple(node)), |
| 761 | .@"if" => return ifExpr(gz, scope, rl.br(), node, tree.ifFull(node)), |
| 753 | 762 | |
| 754 | | .while_simple => return whileExpr(gz, scope, rl, node, tree.whileSimple(node)), |
| 755 | | .while_cont => return whileExpr(gz, scope, rl, node, tree.whileCont(node)), |
| 756 | | .@"while" => return whileExpr(gz, scope, rl, node, tree.whileFull(node)), |
| 763 | .while_simple => return whileExpr(gz, scope, rl.br(), node, tree.whileSimple(node)), |
| 764 | .while_cont => return whileExpr(gz, scope, rl.br(), node, tree.whileCont(node)), |
| 765 | .@"while" => return whileExpr(gz, scope, rl.br(), node, tree.whileFull(node)), |
| 757 | 766 | |
| 758 | | .for_simple => return forExpr(gz, scope, rl, node, tree.forSimple(node)), |
| 759 | | .@"for" => return forExpr(gz, scope, rl, node, tree.forFull(node)), |
| 767 | .for_simple => return forExpr(gz, scope, rl.br(), node, tree.forSimple(node)), |
| 768 | .@"for" => return forExpr(gz, scope, rl.br(), node, tree.forFull(node)), |
| 760 | 769 | |
| 761 | 770 | .slice_open => { |
| 762 | 771 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); |
| ... | ... | @@ -943,7 +952,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 943 | 952 | .error_set_decl => return errorSetDecl(gz, rl, node), |
| 944 | 953 | .array_access => return arrayAccess(gz, scope, rl, node), |
| 945 | 954 | .@"comptime" => return comptimeExprAst(gz, scope, rl, node), |
| 946 | | .@"switch", .switch_comma => return switchExpr(gz, scope, rl, node), |
| 955 | .@"switch", .switch_comma => return switchExpr(gz, scope, rl.br(), node), |
| 947 | 956 | |
| 948 | 957 | .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), |
| 949 | 958 | .@"suspend" => return suspendExpr(gz, scope, node), |