package lib // A named basic over int32 whose method has a pointer receiver. The interface // value slot holds the *E pointer itself for a pointer box, and the E bits for // a value box; both forms must dispatch. type E int32 func (e *E) Error() (s string) { if *e == 1 { return "one" } return "other" } func MK() (p *E) { x := E(1) return &x } type C int32 func (c *C) Error() (s string) { if *c == 1 { return "cone" } return "cother" } // A constant of the value type: the make-interface site boxes it inline with // typeID named:...C, so dispatch needs the value form of the pointer-receiver // method and materializeIfaceValue has to materialize a copy to call on. const K C = 1 type S struct { V int32 } func (s *S) Error() (out string) { if s.V == 1 { return "sone" } return "sother" } // Moxie's builtin error is interface { Error() string; String() string }. func (s *S) String() (out string) { return s.Error() } func NS() (p *S) { x := S{V: 1} return &x }