Files
zig/test/cases/compile_errors/invalid_extern_function_call.zig
mlugg 107b65ec5d Sema: explain why we tried to call an extern fn at comptime
I recently saw a user hit the "comptime call of extern function" error,
and get confused because they didn't know why the scope was `comptime`.
So, use `explainWhyBlockIsComptime` on this and related errors to add
all the relevant notes.

The added test case shows the motivating situation.
2025-01-29 18:43:24 +00:00

16 lines
353 B
Zig

const x = @extern(*const fn () callconv(.c) void, .{ .name = "foo" });
export fn entry0() void {
comptime x();
}
export fn entry1() void {
@call(.always_inline, x, .{});
}
// error
//
// :4:15: error: comptime call of extern function
// :4:5: note: 'comptime' keyword forces comptime evaluation
// :8:5: error: inline call of extern function