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

Comments

@reusee
Copy link

@reusee 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 this to the Go1.18 milestone Sep 30, 2021
@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 30, 2021

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

Loading

@tinti
Copy link

@tinti tinti commented Oct 6, 2021

Hi all,

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

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Oct 7, 2021

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.

Loading

@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

@griesemer griesemer commented Oct 7, 2021

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 7, 2021

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

Loading

@gopherbot gopherbot closed this in 5780be4 Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants