mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check for x := Abc { f: fn () ? {} }
mismatch, when f
is fn ()
This commit is contained in:
parent
6c6bb08547
commit
9fabf9f20c
@ -144,6 +144,9 @@ pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &ast.TypeSym
|
||||
if got_fn.params.len != exp_fn.params.len {
|
||||
return false
|
||||
}
|
||||
if got_fn.return_type.has_flag(.optional) != exp_fn.return_type.has_flag(.optional) {
|
||||
return false
|
||||
}
|
||||
if !c.check_basic(got_fn.return_type, exp_fn.return_type) {
|
||||
return false
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
vlib/v/checker/tests/fn_check_for_matching_optional_result_in_fields.vv:7:3: error: cannot assign to field `f`: expected `fn (voidptr)`, not `fn (voidptr) ?`
|
||||
5 | fn main() {
|
||||
6 | a := Abc{
|
||||
7 | f: fn (data voidptr) ? {}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
8 | }
|
||||
9 | println(a)
|
@ -0,0 +1,10 @@
|
||||
struct Abc {
|
||||
f fn (voidptr)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
a := Abc{
|
||||
f: fn (data voidptr) ? {}
|
||||
}
|
||||
println(a)
|
||||
}
|
Loading…
Reference in New Issue
Block a user