If a type is defined twice in a given package, this can lead to unfortunate interface
assignment errors. As an example, in the code above, "type Foo int" exists
twice. The error message is
prog.go:9: Foo redeclared in this block
previous declaration at prog.go:3
prog.go:18: cannot convert Bar literal (type Bar) to type Fooer:
Bar does not implement Fooer (wrong type for Foo method)
have Foo() Foo
want Foo() Foo
In this particular case it's fine because the "Foo redeclared" error comes
first, but in my actual code the interface conversion error was returned first and then
there were more errors before the redeclaration error.
The text was updated successfully, but these errors were encountered:
@btracey - Can you post the code where you got the interface conversion error before the redeclaration error ? And possibly those "more errors".
In my testing, the errors come linearly in the order in which they are written in the source code. If I redeclare before trying to convert the interface, it gives me the redeclaration error before. Vice-versa, it gives the interface conversion error before. This seems like reasonable behavior to me.
Sorry, this bug report is from a long time ago and I don't have any memory of what the code would have been. I believe though that the problem was I had a many compile errors, and so I was only getting the error saying the interface type can't be converted, and the redeclared error. was not printed
Is interface conversion the only place where this problem can appear? If so, would it be enough to return OCONVIFACE in assignop when the have and want strings match? This is considering the fact that the typechecker only reports the mentioned error when the returned Op == 0.