Sema: improve error message when calling optional function

Co-authored-by: wrongnull <wrongnull@gmail.com>
This commit is contained in:
Veikka Tuominen
2023-05-22 13:23:21 +03:00
parent 957f269a42
commit eef92753c7
2 changed files with 54 additions and 33 deletions

View File

@@ -0,0 +1,17 @@
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'