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, go/types: recursive type matching regression #48695

Closed
reusee opened this issue Sep 30, 2021 · 5 comments
Closed

cmd/compile, go/types: recursive type matching regression #48695

reusee opened this issue Sep 30, 2021 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@reusee
Copy link

reusee commented Sep 30, 2021

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

$ go version
go version devel go1.18-66562692880 Thu Sep 30 01:32:54 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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\reus\AppData\Local\go-build
set GOENV=C:\Users\reus\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\reus\go\pkg\mod
set GONOPROXY=github.com/reusee/*
set GONOSUMDB=github.com/reusee/*
set GOOS=windows
set GOPATH=C:\Users\reus\go
set GOPRIVATE=github.com/reusee/*
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Users\reus\sdk\gotip
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\reus\sdk\gotip\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.18-66562692880 Thu Sep 30 01:32:54 2021 +0000
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\reus\AppData\Local\Temp\go-build2696702073=/tmp/go-build -gno-record-gcc-switches
GOROOT/bin/go version: go version devel go1.18-66562692880 Thu Sep 30 01:32:54 2021 +0000 windows/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.18-66562692880 Thu Sep 30 01:32:54 2021 +0000
gdb --version: GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 10.2

What did you do?

package main

func Foo[
        T any,
        P interface {
                ~func(T) P
        },
](P) {
}

func main() {
        type P func(int) P
        Foo(P(nil))
}

What did you expect to see?

compile OK

What did you see instead?

.\a.go:5:2: type P = P does not match func(T) P

@griesemer The program used to be accepted by the compiler before 435718e

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 30, 2021
@ALTree ALTree added this to the Go1.18 milestone Sep 30, 2021
@griesemer
Copy link
Contributor

This looks like a regression, indeed. Thanks for reporting.

@tinti
Copy link

tinti commented Oct 6, 2021

Hi all,

What do you think of detecting the recursive loop call and mask only after that?

@griesemer
Copy link
Contributor

Slightly simplified reproducer:

func f[P func(T) P, T any]() {}

func _() {
        type P func(int) P
        _ = f[P]
}

Constraint type inference fails too early, it seems. Disabling the new mask/unmask steps in the unifier appears to "fix" this. Investigating.

@findleyr findleyr changed the title cmd/compile: recursive type matching regression cmd/compile, go/types: recursive type matching regression Oct 7, 2021
@griesemer
Copy link
Contributor

The fix for #48619 was incorrect. Will rework that fix.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/354690 mentions this issue: cmd/compile/internal/types2: fix unification (again)

@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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants