1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

table: make table.check ret false & update fn args check

This commit is contained in:
joe-conigliaro 2020-05-05 02:34:11 +10:00
parent d7e7113047
commit 2bb995274e
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1

View File

@ -435,6 +435,11 @@ pub fn (t &Table) check(got, expected Type) bool {
exp_is_ptr := expected.is_ptr()
// println('check: $got_type_sym.name, $exp_type_sym.name')
// # NOTE: use idxs here, and symbols below for perf
if got_idx == exp_idx {
// this is returning true even if one type is a ptr
// and the other is not, is this correct behaviour?
return true
}
if got_idx == none_type_idx {
// TODO
return true
@ -531,20 +536,17 @@ pub fn (t &Table) check(got, expected Type) bool {
exp_info := exp_type_sym.info as FnType
if got_info.func.args.len == exp_info.func.args.len {
mut matching := false
for i, arg in got_info.func.args {
for i, got_arg in got_info.func.args {
exp_arg := exp_info.func.args[i]
matching = arg.typ.idx() == exp_arg.typ.idx() || exp_arg.typ == table.voidptr_type
}
if matching {
return true
}
}
}
if got_idx != exp_idx {
// && got.typ.name != expected.typ.name*/
matching = t.check(got_arg.typ, exp_arg.typ)
if !matching {
return false
}
return true
}
return matching
}
}
return false
}
// Once we have a module format we can read from module file instead