Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/types, types2: better error message for invalid use of constraint …
…type Fixes #42881. Change-Id: If800c5f90c0034d192bf8b6649e5cfda96df48cb Reviewed-on: https://go-review.googlesource.com/c/go/+/410954 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
- Loading branch information
Showing
4 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/cmd/compile/internal/types2/testdata/fixedbugs/issue42881.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
type ( | ||
T1 interface{ comparable } | ||
T2 interface{ int } | ||
) | ||
|
||
var ( | ||
_ comparable // ERROR cannot use type comparable outside a type constraint: interface is \(or embeds\) comparable | ||
_ T1 // ERROR cannot use type T1 outside a type constraint: interface is \(or embeds\) comparable | ||
_ T2 // ERROR cannot use type T2 outside a type constraint: interface contains type constraints | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
type ( | ||
T1 interface{ comparable } | ||
T2 interface{ int } | ||
) | ||
|
||
var ( | ||
_ comparable // ERROR cannot use type comparable outside a type constraint: interface is \(or embeds\) comparable | ||
_ T1 // ERROR cannot use type T1 outside a type constraint: interface is \(or embeds\) comparable | ||
_ T2 // ERROR cannot use type T2 outside a type constraint: interface contains type constraints | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters