Source file test/fixedbugs/issue68526.dir/main.go

     1  // Copyright 2024 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 main
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"issue68526.dir/a"
    11  )
    12  
    13  func main() {
    14  	unexported()
    15  	exported()
    16  }
    17  
    18  func unexported() {
    19  	var want struct{ F int }
    20  
    21  	if any(want) != any(a.B{}) || any(want) != any(a.F()) {
    22  		panic("zero value of alias and concrete type not identical")
    23  	}
    24  }
    25  
    26  func exported() {
    27  	var (
    28  		astr a.A[string]
    29  		aint a.A[int]
    30  	)
    31  
    32  	if any(astr) != any(struct{ F string }{}) || any(aint) != any(struct{ F int }{}) {
    33  		panic("zero value of alias and concrete type not identical")
    34  	}
    35  
    36  	if any(astr) == any(aint) {
    37  		panic("zero value of struct{ F string } and struct{ F int } are not distinct")
    38  	}
    39  
    40  	if got := fmt.Sprintf("%T", astr); got != "struct { F string }" {
    41  		panic(got)
    42  	}
    43  }
    44  

View as plain text