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: wrong instantiation of imported type causes typechecker error #48716

Closed
tdakkota opened this issue Oct 1, 2021 · 5 comments
Closed
Labels
FrozenDueToAge generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@tdakkota
Copy link

tdakkota commented Oct 1, 2021

What version of Go are you using (go version)?

$ go version
go version devel go1.18-8ac5cbe05d Fri Oct 1 04:32:04 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

No.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

The reproducer is quite complex, so I pushed it into the repo https://github.com/tdakkota/goissue-48716.
I tried to simplify it, but had no success. It seems bug appears only if Map interface is imported from another package.

What did you expect to see?

Successful compilation.

What did you see instead?

<autogenerated>:1: cannot use cb (type func(alg.Pair[int,struct{}]) bool) as type func(alg.Pair[.shape.int_0,.shape.struct{}_1]) bool in argument to maps.HashMap[.shape.int_0,.shape.struct{}_1].Iterate
@mknyszek mknyszek added generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 4, 2021
@mknyszek mknyszek added this to the Go1.18 milestone Oct 4, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Oct 4, 2021

CC @griesemer @mdempsky @danscales

@cuonglm
Copy link
Member

cuonglm commented Oct 4, 2021

I can't reproduce this with:

go version devel go1.18-3bbc82371e Sat Oct 2 17:29:46 2021 +0000 darwin/arm64

@danscales danscales self-assigned this Oct 4, 2021
@danscales
Copy link
Contributor

Hmm, did you go to the sets directory and run 'go test'. I am able to reproduce at current master, including 3bbc823:

% cd sets
% go test
# github.com/tdakkota/goissue-48716/sets [github.com/tdakkota/goissue-48716/sets.test]
<autogenerated>:1: cannot use cb (type func(maps.Pair[int,struct{}]) bool) as type func(maps.Pair[.shape.int_0,.shape.struct{}_1]) bool in argument to maps.HashMap[.shape.int_0,.shape.struct{}_1].Iterate
FAIL    github.com/tdakkota/goissue-48716/sets [build failed]

I am working on it (roughly know where the problem is, but not fixed yet).

@cuonglm
Copy link
Member

cuonglm commented Oct 5, 2021

Hmm, did you go to the sets directory and run 'go test'. I am able to reproduce at current master, including 3bbc823:

% cd sets
% go test
# github.com/tdakkota/goissue-48716/sets [github.com/tdakkota/goissue-48716/sets.test]
<autogenerated>:1: cannot use cb (type func(maps.Pair[int,struct{}]) bool) as type func(maps.Pair[.shape.int_0,.shape.struct{}_1]) bool in argument to maps.HashMap[.shape.int_0,.shape.struct{}_1].Iterate
FAIL    github.com/tdakkota/goissue-48716/sets [build failed]

I am working on it (roughly know where the problem is, but not fixed yet).

Oh right, I only did go build.

@gopherbot
Copy link

Change https://golang.org/cl/355250 mentions this issue: cmd/compile: some fixes in type substituter for Instantiate

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants