We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.13.3 linux/amd64
Yes
package main import "reflect" type ( FooStruct = struct { x int `some:"foo"` } FooStruct_Ptr *FooStruct FooStructDefined struct { x int `some:"foo"` } FooStructDefined_Ptr *FooStructDefined ) type ( BarStruct = struct { x int `some:"bar"` } BarStruct_Ptr *BarStruct BarStructDefined struct { x int `some:"bar"` } BarStructDefined_Ptr *BarStructDefined ) func main() { var foo *FooStruct var foo_D FooStruct_Ptr var fooD *FooStructDefined var fooD_D FooStructDefined_Ptr _ = (*FooStruct)(fooD) // ok (correct) _ = (*FooStructDefined)(foo) // ok (correct) println(reflect.TypeOf(foo).ConvertibleTo(reflect.TypeOf(fooD))) println(reflect.TypeOf(fooD).ConvertibleTo(reflect.TypeOf(foo))) // _ = (*FooStruct)(fooD_D) // error (correct) // _ = (*FooStructDefined_Ptr)(foo) // error (correct) println(reflect.TypeOf(foo).ConvertibleTo(reflect.TypeOf(fooD_D))) println(reflect.TypeOf(fooD_D).ConvertibleTo(reflect.TypeOf(foo))) // _ = (*FooStruct_Ptr)(fooD) // error (correct) // _ = (*FooStructDefined)(foo_D) // error (correct) println(reflect.TypeOf(fooD).ConvertibleTo(reflect.TypeOf(foo_D))) println(reflect.TypeOf(foo_D).ConvertibleTo(reflect.TypeOf(fooD))) // _ = (*FooStruct_Ptr)(fooD_D) // error (correct) // _ = (*FooStructDefined_Ptr)(foo_D) // error (correct) println(reflect.TypeOf(fooD_D).ConvertibleTo(reflect.TypeOf(foo_D))) println(reflect.TypeOf(foo_D).ConvertibleTo(reflect.TypeOf(fooD_D))) var bar *BarStruct var bar_D BarStruct_Ptr var barD *BarStructDefined var barD_D BarStructDefined_Ptr _ = barD_D _ = (*FooStruct)(bar) // ok (correct) _ = (*FooStruct)(bar_D) // ok (correct) _ = (*FooStruct)(barD) // ok (correct, when ignoring tags, distict underlying types but identical base types, and they are both non-defined) //_ = ( *FooStruct)(barD_D) // error (correct) println(reflect.TypeOf(bar).ConvertibleTo(reflect.TypeOf(foo))) println(reflect.TypeOf(bar_D).ConvertibleTo(reflect.TypeOf(foo))) println(reflect.TypeOf(barD).ConvertibleTo(reflect.TypeOf(foo))) println(reflect.TypeOf(barD_D).ConvertibleTo(reflect.TypeOf(foo))) _ = FooStruct_Ptr(bar) // ok (correct) _ = FooStruct_Ptr(bar_D) // ok (correct) //_ = FooStruct_Ptr(barD) // error (correct) //_ = FooStruct_Ptr(barD_D) // error (correct) println(reflect.TypeOf(bar).ConvertibleTo(reflect.TypeOf(foo_D))) println(reflect.TypeOf(bar_D).ConvertibleTo(reflect.TypeOf(foo_D))) println(reflect.TypeOf(barD).ConvertibleTo(reflect.TypeOf(foo_D))) println(reflect.TypeOf(barD_D).ConvertibleTo(reflect.TypeOf(foo_D))) _ = (*FooStructDefined)(bar) // ok (correct, when ignoring tags, distict underlying types but identical base types, and they are both non-defined) //_ = (*FooStructDefined)(bar_D) // error (correct) //_ = (*FooStructDefined)(barD) // error (correct) //_ = (*FooStructDefined)(barD_D) // error (correct) println(reflect.TypeOf(bar).ConvertibleTo(reflect.TypeOf(fooD))) println(reflect.TypeOf(bar_D).ConvertibleTo(reflect.TypeOf(fooD))) println(reflect.TypeOf(barD).ConvertibleTo(reflect.TypeOf(fooD))) // true (wrong) println(reflect.TypeOf(barD_D).ConvertibleTo(reflect.TypeOf(fooD))) //_ = FooStructDefined_Ptr(bar) // error (correct) //_ = FooStructDefined_Ptr(bar_D) // error (correct) //_ = FooStructDefined_Ptr(barD) // error (correct) //_ = FooStructDefined_Ptr(barD_D) // error (correct) println(reflect.TypeOf(bar).ConvertibleTo(reflect.TypeOf(fooD_D))) println(reflect.TypeOf(bar_D).ConvertibleTo(reflect.TypeOf(fooD_D))) println(reflect.TypeOf(barD).ConvertibleTo(reflect.TypeOf(fooD_D))) println(reflect.TypeOf(barD_D).ConvertibleTo(reflect.TypeOf(fooD_D))) }
The // true (wrong) line should print false.
// true (wrong)
The text was updated successfully, but these errors were encountered:
Looks I made a mistake here. The line _ = (*FooStructDefined)(barD) // error (correct) really compiles. So closed.
_ = (*FooStructDefined)(barD) // error (correct)
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
The
// true (wrong)
line should print false.The text was updated successfully, but these errors were encountered: