aboutsummaryrefslogtreecommitdiff
path: root/test/nilptr3.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-04-19 21:06:53 -0700
committerKeith Randall <khr@golang.org>2016-04-22 16:18:42 +0000
commit3c1a4c1902711c16489ed0c3506df97439ffbd85 (patch)
tree85df4a3a5fe5d7c8eab29ad769307a71443709a2 /test/nilptr3.go
parent32302d6289e9721015d5d7ac99bbce30de47746c (diff)
downloadgo-3c1a4c1902711c16489ed0c3506df97439ffbd85.tar.gz
go-3c1a4c1902711c16489ed0c3506df97439ffbd85.zip
cmd/compile: don't nilcheck newobject and return values from mapaccess{1,2}
They are guaranteed to be non-nil, no point in inserting nil checks for them. Fixes #15390 Change-Id: I3b9a0f2319affc2139dcc446d0a56c6785ae5a86 Reviewed-on: https://go-review.googlesource.com/22291 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/nilptr3.go')
-rw-r--r--test/nilptr3.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/nilptr3.go b/test/nilptr3.go
index 817d2aec74..1bec833fe3 100644
--- a/test/nilptr3.go
+++ b/test/nilptr3.go
@@ -193,3 +193,24 @@ func f4(x *[10]int) {
x = y
_ = &x[9] // ERROR "removed repeated nil check"
}
+
+func m1(m map[int][80]byte) byte {
+ v := m[3] // ERROR "removed nil check"
+ return v[5]
+}
+func m2(m map[int][800]byte) byte {
+ v := m[3] // ERROR "removed nil check"
+ return v[5]
+}
+func m3(m map[int][80]byte) (byte, bool) {
+ v, ok := m[3] // ERROR "removed nil check"
+ return v[5], ok
+}
+func m4(m map[int][800]byte) (byte, bool) {
+ v, ok := m[3] // ERROR "removed nil check"
+ return v[5], ok
+}
+func p1() byte {
+ p := new([100]byte)
+ return p[5] // ERROR "removed nil check"
+}