-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…all_selector
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
vlib/v/checker/tests/option_selector_fn_unwrap_err.vv:7:17: error: to propagate the call, `callback` must return an Option type | ||
5 | | ||
6 | fn callback(foo &Foo) bool { | ||
7 | return foo.func? == callback | ||
| ^ | ||
8 | } | ||
9 | | ||
Details: vlib/v/checker/tests/option_selector_fn_unwrap_err.vv:6:23: details: prepend ? before the declaration of the return type of `callback` | ||
4 | } | ||
5 | | ||
6 | fn callback(foo &Foo) bool { | ||
| ~~~~ | ||
7 | return foo.func? == callback | ||
8 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
struct Foo { | ||
mut: | ||
func ?fn (voidptr) bool | ||
} | ||
|
||
fn callback(foo &Foo) bool { | ||
return foo.func? == callback | ||
} | ||
|
||
fn main() { | ||
t := Foo{} | ||
assert callback(&t) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
struct Foo { | ||
mut: | ||
func ?fn (voidptr) bool = unsafe { nil } | ||
} | ||
|
||
fn callback(foo &Foo) bool { | ||
return foo.func? == callback | ||
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / gcc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tcc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / clang
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / clang (macos-14)
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / msvc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / gcc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / ubuntu-docker-musl
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tcc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tests-sanitize-undefined-clang
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tests-sanitize-address-clang
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tests-sanitize-undefined-gcc
Check failure on line 7 in vlib/v/tests/options/option_fn_voidptr_test.v GitHub Actions / tests-sanitize-memory-clang
|
||
} | ||
|
||
fn test_main() { | ||
t := Foo{ | ||
func: callback | ||
} | ||
assert t.func? == callback | ||
call_fn := t.func? | ||
assert call_fn(&t) | ||
|
||
mut a := Foo{} | ||
a.func = callback | ||
assert a.func? == callback | ||
call_fn2 := a.func? | ||
assert call_fn2(&a) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
struct Foo { | ||
mut: | ||
func ?fn (voidptr) ?bool | ||
} | ||
|
||
fn callback(foo &Foo) ?bool { | ||
return foo.func? == callback | ||
} | ||
|
||
fn test_main() { | ||
t := Foo{} | ||
assert callback(&t) == none | ||
} |