Source file test/fixedbugs/issue38905.go

     1  // compile
     2  
     3  // Copyright 2020 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  // Make sure that literal value can be passed to struct
     8  // blank field with expressions where candiscard(value)
     9  // returns false, see #38905.
    10  
    11  package p
    12  
    13  type t struct{ _ u }
    14  type u [10]struct{ f int }
    15  
    16  func f(x int) t   { return t{u{{1 / x}, {1 % x}}} }
    17  func g(p *int) t  { return t{u{{*p}}} }
    18  func h(s []int) t { return t{u{{s[0]}}} }
    19  

View as plain text