@@ -356,6 +356,28 @@ static void ir_ref_var(ZigVar *var) {
356356 var->ref_count += 1;
357357}
358358
359+ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) {
360+ ConstExprValue *result = ir_eval_const_value( ira->codegen
361+ , scope
362+ , node
363+ , ira->codegen->builtin_types.entry_type
364+ , ira->new_irb.exec->backward_branch_count
365+ , ira->new_irb.exec->backward_branch_quota
366+ , nullptr
367+ , nullptr
368+ , node
369+ , nullptr
370+ , ira->new_irb.exec
371+ , nullptr
372+ );
373+
374+ if (type_is_invalid(result->type))
375+ return ira->codegen->builtin_types.entry_invalid;
376+
377+ assert(result->special != ConstValSpecialRuntime);
378+ return result->data.x_type;
379+ }
380+
359381static IrBasicBlock *ir_create_basic_block(IrBuilder *irb, Scope *scope, const char *name_hint) {
360382 IrBasicBlock *result = allocate<IrBasicBlock>(1);
361383 result->scope = scope;
@@ -13875,7 +13897,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
1387513897 IrInstruction *casted_arg;
1387613898 if (param_decl_node->data.param_decl.var_token == nullptr) {
1387713899 AstNode *param_type_node = param_decl_node->data.param_decl.type;
13878- ZigType *param_type = analyze_type_expr (ira->codegen , *exec_scope, param_type_node);
13900+ ZigType *param_type = ir_analyze_type_expr (ira, *exec_scope, param_type_node);
1387913901 if (type_is_invalid(param_type))
1388013902 return false;
1388113903
@@ -13915,7 +13937,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1391513937 } else {
1391613938 if (param_decl_node->data.param_decl.var_token == nullptr) {
1391713939 AstNode *param_type_node = param_decl_node->data.param_decl.type;
13918- ZigType *param_type = analyze_type_expr (ira->codegen , *child_scope, param_type_node);
13940+ ZigType *param_type = ir_analyze_type_expr (ira, *child_scope, param_type_node);
1391913941 if (type_is_invalid(param_type))
1392013942 return false;
1392113943
@@ -14296,7 +14318,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call
1429614318 }
1429714319
1429814320 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
14299- ZigType *specified_return_type = analyze_type_expr (ira->codegen , exec_scope, return_type_node);
14321+ ZigType *specified_return_type = ir_analyze_type_expr (ira, exec_scope, return_type_node);
1430014322 if (type_is_invalid(specified_return_type))
1430114323 return ira->codegen->invalid_instruction;
1430214324 ZigType *return_type;
@@ -14532,7 +14554,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call
1453214554
1453314555 if (fn_proto_node->data.fn_proto.return_var_token == nullptr) {
1453414556 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
14535- ZigType *specified_return_type = analyze_type_expr (ira->codegen , impl_fn->child_scope, return_type_node);
14557+ ZigType *specified_return_type = ir_analyze_type_expr (ira, impl_fn->child_scope, return_type_node);
1453614558 if (type_is_invalid(specified_return_type))
1453714559 return ira->codegen->invalid_instruction;
1453814560 if (fn_proto_node->data.fn_proto.auto_err_set) {
@@ -14559,7 +14581,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call
1455914581 if (call_instruction->is_async) {
1456014582 AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type;
1456114583 if (async_allocator_type_node != nullptr) {
14562- ZigType *async_allocator_type = analyze_type_expr (ira->codegen , impl_fn->child_scope, async_allocator_type_node);
14584+ ZigType *async_allocator_type = ir_analyze_type_expr (ira, impl_fn->child_scope, async_allocator_type_node);
1456314585 if (type_is_invalid(async_allocator_type))
1456414586 return ira->codegen->invalid_instruction;
1456514587 inst_fn_type_id.async_allocator_type = async_allocator_type;
0 commit comments