Source file test/fixedbugs/issue4323.go

     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  }
    32  

View as plain text