diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 24ab5ed0b7..0c27aae549 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -333,7 +333,7 @@ fn verror(s string) { util.verror('builder error', s) } -pub fn (mut b Builder) timing_message(msg string, ms int) { +pub fn (mut b Builder) timing_message(msg string, ms i64) { formatted_message := '$msg: ${util.bold(ms.str())} ms' if b.pref.show_timings { println(formatted_message) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 7d993f51e5..3737745f50 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -963,7 +963,9 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type { // } // same ancestor? let it be if exp_arg_sym.parent_idx == got_arg_sym.parent_idx { - continue + if got_arg_sym.parent_idx != 0 { + continue + } } if got_arg_typ != table.void_type { c.error('cannot use type `$got_arg_sym.str()` as type `$exp_arg_sym.str()` in argument ${i+1} to `${left_type_sym.name}.$method_name`', diff --git a/vlib/v/checker/tests/method_wrong_arg_type.out b/vlib/v/checker/tests/method_wrong_arg_type.out new file mode 100644 index 0000000000..5c6d991693 --- /dev/null +++ b/vlib/v/checker/tests/method_wrong_arg_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/method_wrong_arg_type.v:8:4: error: cannot use type `MyEnum` as type `string` in argument 1 to `Sss.info` + 6 | e := MyEnum.x + 7 | s := Sss{} + 8 | s.info(e) + | ~~~~~~~ + 9 | } diff --git a/vlib/v/checker/tests/method_wrong_arg_type.vv b/vlib/v/checker/tests/method_wrong_arg_type.vv new file mode 100644 index 0000000000..55f311d8b1 --- /dev/null +++ b/vlib/v/checker/tests/method_wrong_arg_type.vv @@ -0,0 +1,9 @@ +enum MyEnum { x y z } +pub fn (e MyEnum) str() string { return int(e).str() } +struct Sss { } +fn (s Sss) info(msg string) { println(msg) } +fn main() { + e := MyEnum.x + s := Sss{} + s.info(e) +}