modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue4323.go (about)

     1  // compile
     2  
     3  // Copyright 2012 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  // Issue 4323: inlining of functions with local variables
     8  // forgets to typecheck the declarations in the inlined copy.
     9  
    10  package main
    11  
    12  type reader struct {
    13  	C chan T
    14  }
    15  
    16  type T struct{ C chan []byte }
    17  
    18  var r = newReader()
    19  
    20  func newReader() *reader { return new(reader) }
    21  
    22  func (r *reader) Read(n int) ([]byte, error) {
    23  	req := T{C: make(chan []byte)}
    24  	r.C <- req
    25  	return <-req.C, nil
    26  }
    27  
    28  func main() {
    29  	s, err := r.Read(1)
    30  	_, _ = s, err
    31  }