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
The compiler to report the error type declarations inside generic functions are not currently supported.
What did you see instead?
./prog.go:23:9: p.x undefined (type T has no field or method x)
./prog.go:25:4: p.x undefined (type T has no field or method x)
./prog.go:36:23: cannot use generic type Iterable[T any] without instantiation
./prog.go:74:35: cannot use a type parameter as RHS in type declaration
The compiler reports the error in the S.Build() method only when removing all the unrelated invalid code.
The text was updated successfully, but these errors were encountered:
The error "type declarations inside generic functions are not currently supported" is produced at a later phase in the compiler than those other errors. The compiler exits before that later phase when those other errors happen.
It would be nice to produce them all at one go, but I don't think it is necessary. Lots of non-generic errors have that property currently. For instance, this program:
package main
func f() {
var x int
}
produces a declared but not used error. The following program also has that error, but the compiler exits much earlier and never gets to the phase that produces it.
Closing because the current behavior is OK and there is a lot of other stuff to do first. We can take this up again at some later date if it really seems worthwhile.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have a source file with code that should compile according to the Type Parameter Proposal but is invalid in go1.18:
https://gotipplay.golang.org/p/A4_vnuyiy_H
It contains several errors.
What did you expect to see?
The compiler to report the error
type declarations inside generic functions are not currently supported
.What did you see instead?
The compiler reports the error in the
S.Build()
method only when removing all the unrelated invalid code.The text was updated successfully, but these errors were encountered: