Source file src/internal/types/testdata/fixedbugs/issue59740.go
1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package p 6 7 type F[T any] func(func(F[T])) 8 9 func f(F[int]) {} 10 func g[T any](F[T]) {} 11 12 func _() { 13 g(f /* ERROR "type func(F[int]) of f does not match F[T] (cannot infer T)" */) // type inference/unification must not panic 14 } 15 16 // original test case from issue 17 18 type List[T any] func(T, func(T, List[T]) T) T 19 20 func nil[T any](n T, _ List[T]) T { return n } 21 func cons[T any](h T, t List[T]) List[T] { return func(n T, f func(T, List[T]) T) T { return f(h, t) } } 22 23 func nums[T any](t T) List[T] { 24 return cons(t, cons(t, nil /* ERROR "type func(n T, _ List[T]) T of nil[T] does not match inferred type List[T] for List[T]" */ [T])) 25 } 26