-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Description
by Ostsol:
What steps will reproduce the problem? package main import ( "fmt"; "reflect" ) type A struct { num int; str string } type B struct { A } func (self *A) Set (num int, str string) { self.num = num; self.str = str } func CallSet (val interface{}, num int, str string) { vptr := reflect.NewValue (val).(*reflect.PtrValue); mthd := vptr.Method (0); params := []reflect.Value{reflect.NewValue (num), reflect.NewValue (str)}; mthd.Call (params) } func main () { b := new (B); CallSet (b, 4, "hi"); fmt.Printf ("%d %s\n", b.num, b.str) } What is the expected output? What do you see instead? This program should output the same as if one called 'b.Set (4, "hi")': 4 "hi" Instead it produces a runtime panic, declaring: type mismatch: *main.A != *main.B What is your $GOOS? $GOARCH? linux AMD64 Which revision are you using? (hg identify) 84c2d8accf42+ tip