don't try to eval extern functions at compile time

master
Andrew Kelley 2017-01-08 10:30:05 -05:00
parent 6b36aef306
commit 3ef447fa20
2 changed files with 2 additions and 2 deletions

View File

@ -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;
}

View File

@ -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 {