Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(732)

Delta Between Two Patch Sets: go/ssa/interp/testdata/boundmeth.go

Issue 84650046: code review 84650046: go.tools/go/ssa: perform nil check when taking value of... (Closed)
Left Patch Set: diff -r 953ab6bf85eb https://code.google.com/p/go.tools Created 10 years, 11 months ago
Right Patch Set: diff -r 953ab6bf85eb https://code.google.com/p/go.tools Created 10 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « go/ssa/builder.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Tests of bound method closures. 1 // Tests of bound method closures.
2 2
3 package main 3 package main
4 4
5 import ( 5 import "fmt"
6 » "errors"
7 » "fmt"
8 )
9 6
10 func assert(b bool) { 7 func assert(b bool) {
11 if !b { 8 if !b {
12 panic("oops") 9 panic("oops")
13 } 10 }
14 } 11 }
15 12
16 type I int 13 type I int
17 14
18 func (i I) add(x int) int { 15 func (i I) add(x int) int {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 func (err errString) Error() string { 96 func (err errString) Error() string {
100 return string(err) 97 return string(err)
101 } 98 }
102 99
103 // Regression test for a builder crash. 100 // Regression test for a builder crash.
104 func regress1(x error) func() string { 101 func regress1(x error) func() string {
105 return x.Error 102 return x.Error
106 } 103 }
107 104
108 // Regression test for b/7269: 105 // Regression test for b/7269:
109 // an interface method value performs a nil check. 106 // taking the value of an interface method performs a nil check.
110 func nilInterface() { 107 func nilInterfaceMethodValue() {
111 » err := errors.New("ok") 108 » err := fmt.Errorf("ok")
112 f := err.Error 109 f := err.Error
113 if got := f(); got != "ok" { 110 if got := f(); got != "ok" {
114 panic(got) 111 panic(got)
115 } 112 }
116 113
117 err = nil 114 err = nil
118 if got := f(); got != "ok" { 115 if got := f(); got != "ok" {
119 panic(got) 116 panic(got)
120 } 117 }
121 118
(...skipping 14 matching lines...) Expand all
136 pointerReceiver() 133 pointerReceiver()
137 addressibleValuePointerReceiver() 134 addressibleValuePointerReceiver()
138 promotedReceiver() 135 promotedReceiver()
139 anonStruct() 136 anonStruct()
140 typeCheck() 137 typeCheck()
141 138
142 if e := regress1(errString("hi"))(); e != "hi" { 139 if e := regress1(errString("hi"))(); e != "hi" {
143 panic(e) 140 panic(e)
144 } 141 }
145 142
146 » nilInterface() 143 » nilInterfaceMethodValue()
147 } 144 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b