mirror of
https://github.com/golang/go
synced 2024-11-18 11:55:01 -07:00
871300308a
Whoever called toint() is expecting the {Mpint, Mpflt, Mpcplx} arg to be converted to an integer expression, so it never makes sense to report an error as "constant X truncated to real". Fixes #11580 Change-Id: Iadcb105f0802358a7f77188c2b1e63fe80c5580c Reviewed-on: https://go-review.googlesource.com/34638 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org>
19 lines
565 B
Go
19 lines
565 B
Go
// errorcheck
|
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
var a []int = []int{1: 1}
|
|
var b []int = []int{-1: 1} // ERROR "must be non-negative integer constant"
|
|
|
|
var c []int = []int{2.0: 2}
|
|
var d []int = []int{-2.0: 2} // ERROR "must be non-negative integer constant"
|
|
|
|
var e []int = []int{3 + 0i: 3}
|
|
var f []int = []int{3i: 3} // ERROR "truncated to integer"
|
|
|
|
var g []int = []int{"a": 4} // ERROR "must be non-negative integer constant"
|