aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-08 10:30:05 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-08 10:30:05 -0500
commit3ef447fa20f54f75ad3b9be59768b4ef284cb941 (patch)
treef1106a13d13aa5cc00f24277b4ffb529a7383c00
parent6b36aef3062d1cc2020e74ce4932da9be210108b (diff)
downloadzig-3ef447fa20f54f75ad3b9be59768b4ef284cb941.tar.gz
zig-3ef447fa20f54f75ad3b9be59768b4ef284cb941.zip
don't try to eval extern functions at compile time
-rw-r--r--src/ir.cpp2
-rw-r--r--test/run_tests.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 16467ff440..5554e10215 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -7466,7 +7466,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
if (inline_fn_call) {
// No special handling is needed for compile time evaluation of generic functions.
- if (!fn_entry) {
+ if (!fn_entry || fn_entry->type_entry->data.fn.fn_type_id.is_extern) {
ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression"));
return ira->codegen->builtin_types.entry_invalid;
}
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 9c1a6955ca..0381ebbabe 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1019,7 +1019,7 @@ fn f(x: u32) {
add_compile_fail_case("global variable initializer must be constant expression", R"SOURCE(
extern fn foo() -> i32;
const x = foo();
- )SOURCE", 1, ".tmp_source.zig:3:11: error: global variable initializer requires constant expression");
+ )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression");
add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
fn f(s: []u8) -> []u8 {