aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAlexandros Naskos <alex_naskos@hotmail.com>2020-04-27 15:22:15 +0300
committerAlexandros Naskos <alex_naskos@hotmail.com>2020-04-27 15:22:15 +0300
commit908b908481260322b60f479ccf4cabff72fcc5d5 (patch)
tree56262a1724b716c182ea375ef3ab0a21f3faa352 /src/ir.cpp
parent179423ec2712956e04f188bf8b904e4fb9b48656 (diff)
downloadzig-908b908481260322b60f479ccf4cabff72fcc5d5.tar.gz
zig-908b908481260322b60f479ccf4cabff72fcc5d5.zip
Added tests.
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 8ed22b12cb..64f39bf6f5 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -19706,13 +19706,13 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
return ira->codegen->invalid_inst_gen;
}
- bool extern_fn_in_typeof = false;
-
if (modifier == CallModifierCompileTime) {
+ bool extern_fn_in_typeof = false;
+
// No special handling is needed for compile time evaluation of generic functions.
if (!fn_entry || fn_entry->body_node == nullptr) {
- // We keep evaluating extern functions in TypeOfs
- if (get_scope_typeof(source_instr->scope) != nullptr && fn_entry) {
+ // We keep evaluating extern functions directly in TypeOfs
+ if (fn_entry && source_instr->scope->id == ScopeIdTypeOf) {
extern_fn_in_typeof = true;
} else {
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,
return ira->codegen->invalid_inst_gen;
// Fork a scope of the function with known values for the parameters.
- // If we are evaluating an extern function in a TypeOf, we use the TypeOf's scope instead.
+ // If we are evaluating an extern function in a TypeOf, we use the current scope instead.
Scope *exec_scope = extern_fn_in_typeof ? source_instr->scope : &fn_entry->fndef_scope->base;
size_t next_proto_i = 0;
@@ -19752,7 +19752,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
return ira->codegen->invalid_inst_gen;
}
- for (size_t call_i = 0; call_i < args_len; call_i += 1) {
+ if (!extern_fn_in_typeof) for (size_t call_i = 0; call_i < args_len; call_i += 1) {
IrInstGen *old_arg = args_ptr[call_i];
if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i))