Hi all I ran into this error with generic types. Here is the sample program below, which is my best effort to boil it down to its simplest expression.
I can build and run the program fine with go 1.23.0. However, on line 15 vscode reports the error I put in the comment on that line. I do not know how to determine what tool is instructing vscode to report this error (I imagine it's gopls but I have no proof). package main import "fmt" func main() { b := B{X: &A1{X: B{}}, Y: &A2{X: B{}}} fmt.Printf("b = %#v", b) } type A1 struct { X B } type A2 struct { X B // invalid use of type alias B in recursive type (see go.dev/issue/50729)compilerInvalidDeclCycle } type G[T1, T2 any] struct { X *T1 Y *T2 } type B = G[A1, A2] Here is the same program in the go playground: https://go.dev/play/p/fjy9259UHPY. If I click "Run" I get this output: # [play] vet: ./prog.go:15:4: invalid use of type alias B in recursive type (see go.dev/issue/50729) Go vet failed. b = {X:0xc00009e050 Y:0xc00009e060} Program exited. So "go vet" fails, but the program builds and runs OK. However, if I run "go vet" on my machine, no errors are reported! Can someone explain what is happening? To sum up - the program builds and runs even though an error is reported in vscode and the same error by go vet on the Go playground - go vet reports an error in the Go playground, but not on my machine (they both reportedly run go 1.23.0) - possibly gopls reports this error too? I do not know if it is the tool that tells vscode of the error on my machine (I run gopls 0.16.1) What I'd like to know: - if someone can tell me how to determine what tool is telling vscode to report this error, it would help me find where to report this issue - if someone could confirm whether the program is indeed supposed to be correct, it would also help me (I suspect it should be correct, as it builds and runs successfully) Thanks in advance -- Arnaud PS: Apologies for the html-formatted email, but I couldn't figure out how to paste code into gmail without losing all the indentation -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJ6cK1YR%3DEQpiKtyk1uC5FCniVgpWp3fYr%2B9BMVbyu%3DELAHCBw%40mail.gmail.com.