2012-12-05 16:46:45 -07:00
|
|
|
// errorcheck
|
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
2012-12-05 16:46:45 -07:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Issue 4251: slice with inverted range is an error.
|
|
|
|
|
|
|
|
package p
|
|
|
|
|
|
|
|
func F1(s []byte) []byte {
|
2020-12-09 13:28:15 -07:00
|
|
|
return s[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices"
|
2012-12-05 16:46:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func F2(a [10]byte) []byte {
|
2020-12-09 13:28:15 -07:00
|
|
|
return a[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices"
|
2012-12-05 16:46:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func F3(s string) string {
|
2020-12-09 13:28:15 -07:00
|
|
|
return s[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices"
|
2012-12-05 16:46:45 -07:00
|
|
|
}
|