| ... | @@ -19706,13 +19706,13 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19706,13 +19706,13 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19706 | return ira->codegen->invalid_inst_gen; | 19706 | return ira->codegen->invalid_inst_gen; |
| 19707 | } | 19707 | } |
| 19708 | | 19708 | |
| 19709 | bool extern_fn_in_typeof = false; | | |
| 19710 | | | |
| 19711 | if (modifier == CallModifierCompileTime) { | 19709 | if (modifier == CallModifierCompileTime) { |
| | 19710 | bool extern_fn_in_typeof = false; |
| | 19711 | |
| 19712 | // No special handling is needed for compile time evaluation of generic functions. | 19712 | // No special handling is needed for compile time evaluation of generic functions. |
| 19713 | if (!fn_entry || fn_entry->body_node == nullptr) { | 19713 | if (!fn_entry || fn_entry->body_node == nullptr) { |
| 19714 | // We keep evaluating extern functions in TypeOfs | 19714 | // We keep evaluating extern functions directly in TypeOfs |
| 19715 | if (get_scope_typeof(source_instr->scope) != nullptr && fn_entry) { | 19715 | if (fn_entry && source_instr->scope->id == ScopeIdTypeOf) { |
| 19716 | extern_fn_in_typeof = true; | 19716 | extern_fn_in_typeof = true; |
| 19717 | } else { | 19717 | } else { |
| 19718 | ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to evaluate constant expression")); | 19718 | ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to evaluate constant expression")); |
| ... | @@ -19724,7 +19724,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19724,7 +19724,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19724 | return ira->codegen->invalid_inst_gen; | 19724 | return ira->codegen->invalid_inst_gen; |
| 19725 | | 19725 | |
| 19726 | // Fork a scope of the function with known values for the parameters. | 19726 | // Fork a scope of the function with known values for the parameters. |
| 19727 | // If we are evaluating an extern function in a TypeOf, we use the TypeOf's scope instead. | 19727 | // If we are evaluating an extern function in a TypeOf, we use the current scope instead. |
| 19728 | Scope *exec_scope = extern_fn_in_typeof ? source_instr->scope : &fn_entry->fndef_scope->base; | 19728 | Scope *exec_scope = extern_fn_in_typeof ? source_instr->scope : &fn_entry->fndef_scope->base; |
| 19729 | | 19729 | |
| 19730 | size_t next_proto_i = 0; | 19730 | size_t next_proto_i = 0; |
| ... | @@ -19752,7 +19752,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19752,7 +19752,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19752 | return ira->codegen->invalid_inst_gen; | 19752 | return ira->codegen->invalid_inst_gen; |
| 19753 | } | 19753 | } |
| 19754 | | 19754 | |
| 19755 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19755 | if (!extern_fn_in_typeof) for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 19756 | IrInstGen *old_arg = args_ptr[call_i]; | 19756 | IrInstGen *old_arg = args_ptr[call_i]; |
| 19757 | | 19757 | |
| 19758 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) | 19758 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |