authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:30:05-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:30:05-05:00
log3ef447fa20f54f75ad3b9be59768b4ef284cb941
treef1106a13d13aa5cc00f24277b4ffb529a7383c00
parent6b36aef3062d1cc2020e74ce4932da9be210108b

don't try to eval extern functions at compile time


2 files changed, 2 insertions(+), 2 deletions(-)

src/ir.cpp+1-1
......@@ -7466,7 +7466,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
74667466
74677467 if (inline_fn_call) {
74687468 // No special handling is needed for compile time evaluation of generic functions.
7469 if (!fn_entry) {
7469 if (!fn_entry || fn_entry->type_entry->data.fn.fn_type_id.is_extern) {
74707470 ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression"));
74717471 return ira->codegen->builtin_types.entry_invalid;
74727472 }
test/run_tests.cpp+1-1
......@@ -1019,7 +1019,7 @@ fn f(x: u32) {
10191019 add_compile_fail_case("global variable initializer must be constant expression", R"SOURCE(
10201020extern fn foo() -> i32;
10211021const x = foo();
1022 )SOURCE", 1, ".tmp_source.zig:3:11: error: global variable initializer requires constant expression");
1022 )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression");
10231023
10241024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
10251025fn f(s: []u8) -> []u8 {