| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2017 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 |
// Verify that copy arguments requirements are enforced by the |
| 8 |
// compiler. |
| 9 |
|
| 10 |
package main |
| 11 |
|
| 12 |
func main() { |
| 13 |
|
| 14 |
si := make([]int, 8) |
| 15 |
sf := make([]float64, 8) |
| 16 |
|
| 17 |
_ = copy() // ERROR "not enough arguments" |
| 18 |
_ = copy(1, 2, 3) // ERROR "too many arguments" |
| 19 |
|
| 20 |
_ = copy(si, "hi") // ERROR "have different element types(.*int.*string| int and byte)" |
| 21 |
_ = copy(si, sf) // ERROR "have different element types.*int.*float64" |
| 22 |
|
| 23 |
_ = copy(1, 2) // ERROR "must be slices; have int, int|argument must be a slice; have 1" |
| 24 |
_ = copy(1, si) // ERROR "first argument to copy should be|argument must be a slice; have 1" |
| 25 |
_ = copy(si, 2) // ERROR "second argument to copy should be|argument must be a slice; have 2" |
| 26 |
|
| 27 |
} |