From 2bb995274eba4c4c6bb6988bfbe69e3b50fec4bf Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Tue, 5 May 2020 02:34:11 +1000 Subject: [PATCH] table: make table.check ret false & update fn args check --- vlib/v/table/table.v | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index fd8fe3092f..757c922a58 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -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 + matching = t.check(got_arg.typ, exp_arg.typ) + if !matching { + return false + } } + return matching } } - if got_idx != exp_idx { - // && got.typ.name != expected.typ.name*/ - return false - } - return true + return false } // Once we have a module format we can read from module file instead