1 package lib
2 3 // A named basic over int32 whose method has a pointer receiver. The interface
4 // value slot holds the *E pointer itself for a pointer box, and the E bits for
5 // a value box; both forms must dispatch.
6 type E int32
7 8 func (e *E) Error() (s string) {
9 if *e == 1 {
10 return "one"
11 }
12 return "other"
13 }
14 15 func MK() (p *E) {
16 x := E(1)
17 return &x
18 }
19 20 type C int32
21 22 func (c *C) Error() (s string) {
23 if *c == 1 {
24 return "cone"
25 }
26 return "cother"
27 }
28 29 // A constant of the value type: the make-interface site boxes it inline with
30 // typeID named:...C, so dispatch needs the value form of the pointer-receiver
31 // method and materializeIfaceValue has to materialize a copy to call on.
32 const K C = 1
33 34 type S struct {
35 V int32
36 }
37 38 func (s *S) Error() (out string) {
39 if s.V == 1 {
40 return "sone"
41 }
42 return "sother"
43 }
44 45 // Moxie's builtin error is interface { Error() string; String() string }.
46 func (s *S) String() (out string) {
47 return s.Error()
48 }
49 50 func NS() (p *S) {
51 x := S{V: 1}
52 return &x
53 }
54