diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-05-22 13:23:21 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-05-22 19:11:38 +0300 |
| commit | eef92753c7cf677191adc40a7cdf7561ceb43bdb (patch) | |
| tree | abd8efecb1544b393d713cf62f9bfa5a04db1df0 /test/cases/compile_errors | |
| parent | 957f269a4259207400f7bac9bd8a200c1c5a53d7 (diff) | |
| download | zig-eef92753c7cf677191adc40a7cdf7561ceb43bdb.tar.gz zig-eef92753c7cf677191adc40a7cdf7561ceb43bdb.zip | |
Sema: improve error message when calling optional function
Co-authored-by: wrongnull <wrongnull@gmail.com>
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/call_optional_function.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/compile_errors/call_optional_function.zig b/test/cases/compile_errors/call_optional_function.zig new file mode 100644 index 0000000000..ce8c3a4d23 --- /dev/null +++ b/test/cases/compile_errors/call_optional_function.zig @@ -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' |
