You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: //go:build file version ignored when calling generic fn which has related type params (reproduces with 1.21 and 1.20, not at tip) #64759
This looks like a typechecker issue. My understanding of 804d786's commit message is that this should be valid. (Not sure if there's more permanent documentation describing the expected behavior here; for example, I don't see any mention of the backwards compatibility logic for M >= 21 at https://pkg.go.dev/cmd/go. /cc @rsc)
To double-check, I added a print statement in the relevant code section, and it does indeed select go1.18 for that file.
Please verify that you are indeed using a new compiler version.
I'm going to close this for now. Feel free to re-open if you have additional evidence, thanks.
changed the title [-]cmd/compile: //go:build file version ignored when calling generic fn which has related type params[/-][+][go1.21] cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/+]on Dec 20, 2023
changed the title [-][go1.21] cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/-][+]cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/+]on Dec 20, 2023
Confirming that this issue exists for go1.21.5.
It appears that we don't have correct position information when computing a type set and then the type checker doesn't use the file-specific version information. This is definitely a bug.
Smaller reproducer source code:
//go:build go1.18package p
funcf[S~[]E, Eany](S) {}
func_() {
f([]string{})
}
Forward-compatibility (specifically, the ability to have a go:build line indicate a Go version that is younger than the Go version used in the .mod file) was introduced with Go 1.21.
The fix for this issue does not need to (and cannot) be backported to 1.20.
Activity
mdempsky commentedon Dec 15, 2023
This looks like a typechecker issue. My understanding of 804d786's commit message is that this should be valid. (Not sure if there's more permanent documentation describing the expected behavior here; for example, I don't see any mention of the backwards compatibility logic for M >= 21 at https://pkg.go.dev/cmd/go. /cc @rsc)
/cc @griesemer @findleyr
griesemer commentedon Dec 19, 2023
I cannot reproduce this. With
and
x.go:compilation succeeds:
To double-check, I added a print statement in the relevant code section, and it does indeed select
go1.18for that file.Please verify that you are indeed using a new compiler version.
I'm going to close this for now. Feel free to re-open if you have additional evidence, thanks.
[-]cmd/compile: //go:build file version ignored when calling generic fn which has related type params[/-][+][go1.21] cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/+]corhere commentedon Dec 20, 2023
@griesemer I know that Go 1.22 is not affected. I said as much in the issue report. The issue is reproducible on Go 1.21.5.
[-][go1.21] cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/-][+]cmd/compile: //go:build file version ignored when calling generic fn which has related type params [1.21 only][/+]griesemer commentedon Dec 20, 2023
@corhere Ah. Apologies for not reading more carefully.
Hm, the relevant code didn't exist for 1.21.5 I believe. Not sure if we can easily/should backport.
Reopening, to determine next steps.
griesemer commentedon Dec 21, 2023
Confirming that this issue exists for go1.21.5.
It appears that we don't have correct position information when computing a type set and then the type checker doesn't use the file-specific version information. This is definitely a bug.
Smaller reproducer source code:
15 remaining items
griesemer commentedon Jan 11, 2024
Forward-compatibility (specifically, the ability to have a
go:buildline indicate a Go version that is younger than the Go version used in the.modfile) was introduced with Go 1.21.The fix for this issue does not need to (and cannot) be backported to 1.20.
griesemer commentedon Jan 11, 2024
This was fixed at tip (1.22).
[release-branch.go1.21] go/types, types2: don't lose position info of…
go/types, types2: don't lose position info of interface embeddings
Replace uses of slices.Clone()
Replace uses of slices.Clone()
Replace uses of slices.Clone()
Replace uses of slices.Clone()
Replace uses of slices.Clone()
Replace uses of slices.Clone()