| ... | ... | @@ -789,8 +789,17 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 789 | 789 | return rvalue(gz, ri, result, node); |
| 790 | 790 | }, |
| 791 | 791 | |
| 792 | | .error_union => return simpleBinOp(gz, scope, ri, node, .error_union_type), |
| 793 | | .merge_error_sets => return simpleBinOp(gz, scope, ri, node, .merge_error_sets), |
| 792 | .error_union, .merge_error_sets => |tag| { |
| 793 | const inst_tag: Zir.Inst.Tag = switch (tag) { |
| 794 | .error_union => .error_union_type, |
| 795 | .merge_error_sets => .merge_error_sets, |
| 796 | else => unreachable, |
| 797 | }; |
| 798 | const lhs = try reachableTypeExpr(gz, scope, node_datas[node].lhs, node); |
| 799 | const rhs = try reachableTypeExpr(gz, scope, node_datas[node].rhs, node); |
| 800 | const result = try gz.addPlNode(inst_tag, node, Zir.Inst.Bin{ .lhs = lhs, .rhs = rhs }); |
| 801 | return rvalue(gz, ri, result, node); |
| 802 | }, |
| 794 | 803 | |
| 795 | 804 | .bool_and => return boolBinOp(gz, scope, ri, node, .bool_br_and), |
| 796 | 805 | .bool_or => return boolBinOp(gz, scope, ri, node, .bool_br_or), |
| ... | ... | @@ -1366,6 +1375,7 @@ fn fnProtoExprInner( |
| 1366 | 1375 | assert(param_type_node != 0); |
| 1367 | 1376 | var param_gz = block_scope.makeSubBlock(scope); |
| 1368 | 1377 | defer param_gz.unstack(); |
| 1378 | param_gz.is_comptime = true; |
| 1369 | 1379 | const param_type = try fullBodyExpr(&param_gz, scope, coerced_type_ri, param_type_node, .normal); |
| 1370 | 1380 | const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1); |
| 1371 | 1381 | _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node); |
| ... | ... | @@ -1382,18 +1392,19 @@ fn fnProtoExprInner( |
| 1382 | 1392 | }; |
| 1383 | 1393 | |
| 1384 | 1394 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) |
| 1385 | | try expr( |
| 1395 | try comptimeExpr( |
| 1386 | 1396 | &block_scope, |
| 1387 | 1397 | scope, |
| 1388 | 1398 | .{ .rl = .{ .coerced_ty = try block_scope.addBuiltinValue(fn_proto.ast.callconv_expr, .calling_convention) } }, |
| 1389 | 1399 | fn_proto.ast.callconv_expr, |
| 1400 | .@"callconv", |
| 1390 | 1401 | ) |
| 1391 | 1402 | else if (implicit_ccc) |
| 1392 | 1403 | try block_scope.addBuiltinValue(node, .calling_convention_c) |
| 1393 | 1404 | else |
| 1394 | 1405 | .none; |
| 1395 | 1406 | |
| 1396 | | const ret_ty = try expr(&block_scope, scope, coerced_type_ri, fn_proto.ast.return_type); |
| 1407 | const ret_ty = try comptimeExpr(&block_scope, scope, coerced_type_ri, fn_proto.ast.return_type, .function_ret_ty); |
| 1397 | 1408 | |
| 1398 | 1409 | const result = try block_scope.addFunc(.{ |
| 1399 | 1410 | .src_node = fn_proto.ast.proto_node, |
| ... | ... | @@ -3916,7 +3927,7 @@ fn ptrType( |
| 3916 | 3927 | gz.astgen.source_column = source_column; |
| 3917 | 3928 | |
| 3918 | 3929 | const addrspace_ty = try gz.addBuiltinValue(ptr_info.ast.addrspace_node, .address_space); |
| 3919 | | addrspace_ref = try expr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, ptr_info.ast.addrspace_node); |
| 3930 | addrspace_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, ptr_info.ast.addrspace_node, .@"addrspace"); |
| 3920 | 3931 | trailing_count += 1; |
| 3921 | 3932 | } |
| 3922 | 3933 | if (ptr_info.ast.align_node != 0) { |
| ... | ... | @@ -3924,13 +3935,13 @@ fn ptrType( |
| 3924 | 3935 | gz.astgen.source_line = source_line; |
| 3925 | 3936 | gz.astgen.source_column = source_column; |
| 3926 | 3937 | |
| 3927 | | align_ref = try expr(gz, scope, coerced_align_ri, ptr_info.ast.align_node); |
| 3938 | align_ref = try comptimeExpr(gz, scope, coerced_align_ri, ptr_info.ast.align_node, .@"align"); |
| 3928 | 3939 | trailing_count += 1; |
| 3929 | 3940 | } |
| 3930 | 3941 | if (ptr_info.ast.bit_range_start != 0) { |
| 3931 | 3942 | assert(ptr_info.ast.bit_range_end != 0); |
| 3932 | | bit_start_ref = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, ptr_info.ast.bit_range_start); |
| 3933 | | bit_end_ref = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, ptr_info.ast.bit_range_end); |
| 3943 | bit_start_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, ptr_info.ast.bit_range_start, .type); |
| 3944 | bit_end_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, ptr_info.ast.bit_range_end, .type); |
| 3934 | 3945 | trailing_count += 2; |
| 3935 | 3946 | } |
| 3936 | 3947 | |