| ... | @@ -281,6 +281,15 @@ pub const ResultLoc = union(enum) { | ... | @@ -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 | pub const align_rl: ResultLoc = .{ .ty = .u16_type }; | 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,15 +757,15 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 748 | .field_access => return fieldAccess(gz, scope, rl, node), | 757 | .field_access => return fieldAccess(gz, scope, rl, node), |
| 749 | .float_literal => return floatLiteral(gz, rl, node), | 758 | .float_literal => return floatLiteral(gz, rl, node), |
| 750 | | 759 | |
| 751 | .if_simple => return ifExpr(gz, scope, rl, node, tree.ifSimple(node)), | 760 | .if_simple => return ifExpr(gz, scope, rl.br(), node, tree.ifSimple(node)), |
| 752 | .@"if" => return ifExpr(gz, scope, rl, node, tree.ifFull(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)), | 763 | .while_simple => return whileExpr(gz, scope, rl.br(), node, tree.whileSimple(node)), |
| 755 | .while_cont => return whileExpr(gz, scope, rl, node, tree.whileCont(node)), | 764 | .while_cont => return whileExpr(gz, scope, rl.br(), node, tree.whileCont(node)), |
| 756 | .@"while" => return whileExpr(gz, scope, rl, node, tree.whileFull(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)), | 767 | .for_simple => return forExpr(gz, scope, rl.br(), node, tree.forSimple(node)), |
| 759 | .@"for" => return forExpr(gz, scope, rl, node, tree.forFull(node)), | 768 | .@"for" => return forExpr(gz, scope, rl.br(), node, tree.forFull(node)), |
| 760 | | 769 | |
| 761 | .slice_open => { | 770 | .slice_open => { |
| 762 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); | 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,7 +952,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 943 | .error_set_decl => return errorSetDecl(gz, rl, node), | 952 | .error_set_decl => return errorSetDecl(gz, rl, node), |
| 944 | .array_access => return arrayAccess(gz, scope, rl, node), | 953 | .array_access => return arrayAccess(gz, scope, rl, node), |
| 945 | .@"comptime" => return comptimeExprAst(gz, scope, rl, node), | 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 | .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), | 957 | .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), |
| 949 | .@"suspend" => return suspendExpr(gz, scope, node), | 958 | .@"suspend" => return suspendExpr(gz, scope, node), |