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...@@ -7466,7 +7466,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
74667466
7467 if (inline_fn_call) {7467 if (inline_fn_call) {
7468 // No special handling is needed for compile time evaluation of generic functions.7468 // 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) {
7470 ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression"));7470 ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression"));
7471 return ira->codegen->builtin_types.entry_invalid;7471 return ira->codegen->builtin_types.entry_invalid;
7472 }7472 }
test/run_tests.cpp+1-1
...@@ -1019,7 +1019,7 @@ fn f(x: u32) {...@@ -1019,7 +1019,7 @@ fn f(x: u32) {
1019 add_compile_fail_case("global variable initializer must be constant expression", R"SOURCE(1019 add_compile_fail_case("global variable initializer must be constant expression", R"SOURCE(
1020extern fn foo() -> i32;1020extern fn foo() -> i32;
1021const x = foo();1021const 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
1024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(1024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
1025fn f(s: []u8) -> []u8 {1025fn f(s: []u8) -> []u8 {