Skip to content

Commit

Permalink
go/types/typeutil: compute correct core type for <-chan E | chan E
Browse files Browse the repository at this point in the history
We failed to account for bidirectional channels following unidirectional
channels in the term list.

Fixes gh-1304

(cherry picked from commit edb67bc)
  • Loading branch information
dominikh committed Jul 29, 2022
1 parent ae2dc16 commit 61defc0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/types/typeutil/typeparams.go
Expand Up @@ -52,6 +52,10 @@ func (ts TypeSet) CoreType() types.Type {
// typ is currently a bidirectional channel. The term's type is either also bidirectional, or
// unidirectional. Use the term's type.
typ = ut
} else if ch2.Dir() == types.SendRecv {
// typ is currently a unidirectional channel and the term's type is bidirectional, which means it has no
// effect.
continue
} else if ch1.Dir() != ch2.Dir() {
// typ is not bidirectional and typ and term disagree about the direction
return nil
Expand Down

0 comments on commit 61defc0

Please sign in to comment.