Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: improve error message for invalid use of interface with type constraints #50837

virtuald opened this issue Jan 26, 2022 · 2 comments
help wanted NeedsFix


Copy link

@virtuald virtuald commented Jan 26, 2022

What did you do?

package main

type C interface {

func UseInterface(c C) {}

type Foo struct {
	I C

What did you expect to see?

./prog.go:8:21: interface with type constraints used as function parameter
./prog.go:11:4: interface with type constraints cannot be used as field

What did you see instead?

./prog.go:8:21: interface contains type constraints
./prog.go:11:4: interface contains type constraints
@ianlancetaylor ianlancetaylor changed the title compiler?: Improve interface with type constraint compilation error cmd/compile: improve error message for invalid use of interface with type constraints Jan 26, 2022
@ianlancetaylor ianlancetaylor added help wanted NeedsInvestigation labels Jan 26, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Jan 26, 2022
Copy link

@ianlancetaylor ianlancetaylor commented Jan 26, 2022

@griesemer griesemer added NeedsFix and removed NeedsInvestigation labels Jan 27, 2022
Copy link

@griesemer griesemer commented Jan 27, 2022

The checker.varType function needs a context string so that it can report a context-aware error. Straight-forward to fix, needs some Fingerspitzengefühl for good error messages.

@griesemer griesemer self-assigned this Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
help wanted NeedsFix
None yet

No branches or pull requests

3 participants