Source file test/fixedbugs/issue16949.go

     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|must be integer"
    16  	sink = make([]byte, float64(1.0)) // ERROR "non-integer.*len|must be integer"
    17  
    18  	sink = make([]byte, 0, 1.0)
    19  	sink = make([]byte, 0, float32(1.0)) // ERROR "non-integer.*cap|must be integer"
    20  	sink = make([]byte, 0, float64(1.0)) // ERROR "non-integer.*cap|must be integer"
    21  
    22  	sink = make([]byte, 1+0i)
    23  	sink = make([]byte, complex64(1+0i))  // ERROR "non-integer.*len|must be integer"
    24  	sink = make([]byte, complex128(1+0i)) // ERROR "non-integer.*len|must be integer"
    25  
    26  	sink = make([]byte, 0, 1+0i)
    27  	sink = make([]byte, 0, complex64(1+0i))  // ERROR "non-integer.*cap|must be integer"
    28  	sink = make([]byte, 0, complex128(1+0i)) // ERROR "non-integer.*cap|must be integer"
    29  
    30  }
    31  

View as plain text