mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix fn_array types check (#7376)
This commit is contained in:
parent
042449cd3d
commit
ff2cfd4f38
@ -74,10 +74,12 @@ pub fn (mut c Checker) check_basic(got table.Type, expected table.Type) bool {
|
||||
(exp_type_sym.is_int() && got_type_sym.kind == .enum_) {
|
||||
return true
|
||||
}
|
||||
// TODO
|
||||
// if got_type_sym.kind == .array && exp_type_sym.kind == .array {
|
||||
// return true
|
||||
// }
|
||||
// array fn
|
||||
if got_type_sym.kind == .array && exp_type_sym.kind == .array {
|
||||
if c.table.type_to_str(got) == c.table.type_to_str(expected) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if got_type_sym.kind == .array_fixed && exp_type_sym.kind == .byteptr {
|
||||
info := got_type_sym.info as table.ArrayFixed
|
||||
if info.elem_type.idx() == table.byte_type_idx {
|
||||
|
@ -349,3 +349,20 @@ fn test_fields_anon_fn_with_optional_void_return_type() {
|
||||
}
|
||||
}
|
||||
|
||||
struct Commands {
|
||||
show []fn() string
|
||||
}
|
||||
|
||||
fn a() string {
|
||||
return 'HELLOW'
|
||||
}
|
||||
|
||||
fn b() string {
|
||||
return 'WOLLEH'
|
||||
}
|
||||
|
||||
fn test_fields_array_of_fn() {
|
||||
commands := Commands{show: [a, b]}
|
||||
println(commands.show)
|
||||
assert '$commands.show' == '[fn () string, fn () string]'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user