Source file test/fixedbugs/issue79812.go

     1  // run
     2  
     3  // Copyright 2026 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  type Foo interface {
    10  	~float64
    11  }
    12  
    13  func bar[T Foo](x T, y func(a T) T) T {
    14  	return y(0)
    15  }
    16  
    17  func f[T Foo](x T) T {
    18  	return T(0 + 0i)
    19  }
    20  
    21  func g[T Foo](x T) T {
    22  	return bar(0, f[T])
    23  }
    24  
    25  func main() {
    26  	if got := g(0.0); got != 0 {
    27  		println("unexpected result:", got)
    28  		panic("FAILED")
    29  	}
    30  }
    31  

View as plain text