...
Run Format

Source file test/fixedbugs/issue16949.go

Documentation: test/fixedbugs

     1  // errorcheck
     2  
     3  // Copyright 2016 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  // Ensure that typed non-integer len and cap make arguments are not accepted.
     8  
     9  package main
    10  
    11  var sink []byte
    12  
    13  func main() {
    14  	sink = make([]byte, 1.0)
    15  	sink = make([]byte, float32(1.0)) // ERROR "non-integer.*len"
    16  	sink = make([]byte, float64(1.0)) // ERROR "non-integer.*len"
    17  
    18  	sink = make([]byte, 0, 1.0)
    19  	sink = make([]byte, 0, float32(1.0)) // ERROR "non-integer.*cap"
    20  	sink = make([]byte, 0, float64(1.0)) // ERROR "non-integer.*cap"
    21  
    22  	sink = make([]byte, 1+0i)
    23  	sink = make([]byte, complex64(1+0i))  // ERROR "non-integer.*len"
    24  	sink = make([]byte, complex128(1+0i)) // ERROR "non-integer.*len"
    25  
    26  	sink = make([]byte, 0, 1+0i)
    27  	sink = make([]byte, 0, complex64(1+0i))  // ERROR "non-integer.*cap"
    28  	sink = make([]byte, 0, complex128(1+0i)) // ERROR "non-integer.*cap"
    29  
    30  }
    31  

View as plain text