Here's another unhelpful error: https://go2goplay.golang.org/p/GDxiXiIIti7

Error: "prog.go2:7:11: all type parameters must be named"

Actual problem: the type parameters *were* named, but no constraint was 
given.

func blah[T1, T2](x T1) T2 {  // wrong
func blah[T1, T2 any](x T1) T2 {  // fixed

On Tuesday, 5 January 2021 at 16:10:46 UTC Brian Candler wrote:

> I don't know if this is expected, but this (bad) program causes the go2go 
> playground to give "panic: assertion failed"
>
> https://go2goplay.golang.org/p/VH5SLJNxw3X
>
> - I think it's the compiler itself that's panicing, not the runtime (since 
> it doesn't get as far as the next line).
>
> ----
>
> Aside: my general feeling so far is that the error messages given from go 
> programs which misapply generic syntax can be very unhelpful.  Here's one 
> example:
> https://go2goplay.golang.org/p/m9YUDBTWwpA
>
> Error given: "missing ',' in type argument list"
> Actual problem: a constraint was used in a place where it's not allowed
>

-- 
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/68a51f38-31d2-47f8-aef5-631b033ecf60n%40googlegroups.com.

Reply via email to