zig/test/cases/compile_errors/call_optional_function.zig
r00ster91 ee4ced9683 write function types consistently with a space before fn keyword
Currently, the compiler (like @typeName) writes it `fn(...) Type` but
zig fmt writes it `fn (...) Type` (notice the space after `fn`).
This inconsistency is now resolved and function types are consistently
written the zig fmt way. Before this there were more `fn (...) Type`
occurrences than `fn(...) Type` already.
2023-09-19 15:15:05 +03:00

18 lines
484 B
Zig

pub export fn entry1() void {
const optional_fn: ?fn () void = null;
_ = optional_fn();
}
pub export fn entry2() void {
const optional_fn_ptr: ?*const fn () void = null;
_ = optional_fn_ptr();
}
// error
// backend=stage2
// target=native
//
// :3:9: error: cannot call optional type '?fn () void'
// :3:9: note: consider using '.?', 'orelse' or 'if'
// :7:9: error: cannot call optional type '?*const fn () void'
// :7:9: note: consider using '.?', 'orelse' or 'if'