]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: fix overlap test for union termlist
authorRobert Griesemer <gri@golang.org>
Sat, 2 Apr 2022 00:02:28 +0000 (17:02 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 4 Apr 2022 15:47:50 +0000 (15:47 +0000)
commit35fb79be6abc1a9a0860cd28cae89dda038f5125
tree258ff6fc16776d74b50ba72a2ee954a039902a6a
parentf86f9a3038eb6db513a0ea36bc2af7a13b005e99
go/types, types2: fix overlap test for union termlist

Per the spec, "the type sets of all non-interface terms must be
pairwise disjoint (the pairwise intersection of the type sets must
be empty)" in a union.

For the overlap test, the existing implementation casually mixed
syntactic union terms (which may have interface type) with type set
terms (which are normalized/expanded and must not have interface
type). As a consequence, in some cases the overlap test failed.

This change skips terms with interface types in the overlap test.

Fixes #51607.

Change-Id: I8ae9953db31f0a0428389c6a45a6696aa2450219
Reviewed-on: https://go-review.googlesource.com/c/go/+/397695
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/testdata/examples/constraints.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51607.go [new file with mode: 0644]
src/cmd/compile/internal/types2/union.go
src/go/types/testdata/examples/constraints.go
src/go/types/testdata/fixedbugs/issue51607.go [new file with mode: 0644]
src/go/types/union.go