fix: range over channels returned by binary calls

This commit is contained in:
Julien Levesy
2020-06-18 14:22:03 +02:00
committed by GitHub
parent d252821df3
commit 6486909921
2 changed files with 27 additions and 2 deletions

View File

@@ -135,9 +135,18 @@ func (s *scope) rangeChanType(n *node) *itype {
return t
}
}
if c := n.child[1]; c.typ != nil && c.typ.cat == chanT {
return c.typ
c := n.child[1]
if c.typ == nil {
return nil
}
switch {
case c.typ.cat == chanT:
return c.typ
case c.typ.cat == valueT && c.typ.rtype.Kind() == reflect.Chan:
return &itype{cat: chanT, val: &itype{cat: valueT, rtype: c.typ.rtype.Elem()}}
}
return nil
}