v icon indicating copy to clipboard operation
v copied to clipboard

Build error for same interface argument

Open StringNick opened this issue 3 years ago • 0 comments

V version: V 0.3.0 d6de533.f1ebfb2 OS: macos, macOS, 12.4, 21F79

What did you do?

module main

interface ITest {
	test() int
}

struct Test {
	f fn (ITest)
}

fn (t Test) test() int {
	return 0
}

fn new_test() &Test {
	return &Test{}
}

fn test123(i ITest) {
}

fn main() {
	t := Test{}
	test123(new_test())
	t.f(new_test())
}

What did you expect to see? expected same behavior

What did you see instead? error and different behavior for equal interface argument if function

test/main.v:25:6: error: cannot use `&Test` as `ITest` in argument 1 to `Test.f`
   23 |     t := Test{}
   24 |     test123(new_test())
   25 |     t.f(new_test())
      |         ~~~~~~~~~~
   26 | }

StringNick avatar Jul 26 '22 01:07 StringNick