go/pointer: fix panic due to bogus constraint from value,ok receive operation.
See regression test for explanation.
I audited the code for similar issues and found none.
Many thanks to Daniel Morsing for providing a small
reproducible test case, a rarity for PTA bugs!
Fixes golang/go#9002
LGTM=crawshaw
R=crawshaw
CC=daniel.morsing, golang-codereviews
https://golang.org/cl/163350043
diff --git a/go/pointer/gen.go b/go/pointer/gen.go
index d8f96a7..cfd8241 100644
--- a/go/pointer/gen.go
+++ b/go/pointer/gen.go
@@ -936,7 +936,8 @@
case token.ARROW: // <-x
// We can ignore instr.CommaOk because the node we're
// altering is always at zero offset relative to instr
- a.genLoad(cgn, a.valueNode(instr), instr.X, 0, a.sizeof(instr.Type()))
+ tElem := instr.X.Type().Underlying().(*types.Chan).Elem()
+ a.genLoad(cgn, a.valueNode(instr), instr.X, 0, a.sizeof(tElem))
case token.MUL: // *x
a.genLoad(cgn, a.valueNode(instr), instr.X, 0, a.sizeof(instr.Type()))