mirror of
https://github.com/golang/go
synced 2024-11-18 09:54:57 -07:00
2da9c3e0f9
Follow-up to Change-Id: If6e52c59eab438599d641ecf6f110ebafca740a9 This addresses the remaining tech debt on issue 21979. The aforementioned previous CL silenced one of two mostly redundant compiler errors. However, the silenced error was the more expressive error. This CL now imbues the surviving error with the same level of expressiveness as the old semi-redundant error. Fixes #21979 Change-Id: I3273d48c88bbab073fabe53421d801df621ce321 Reviewed-on: https://go-review.googlesource.com/c/go/+/191079 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
// errorcheck
|
|
|
|
// Copyright 2019 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
|
|
|
|
func f() {
|
|
// old error: "(type untyped string)"
|
|
_ = bool("") // ERROR "cannot convert .. \(type string\) to type bool"
|
|
|
|
// old error: "(type untyped number)"
|
|
_ = bool(1) // ERROR "cannot convert 1 \(type int\) to type bool"
|
|
|
|
// old error: "(type untyped number)"
|
|
_ = bool(1.0) // ERROR "cannot convert 1 \(type float64\) to type bool"
|
|
|
|
// old error: "(type untyped number)"
|
|
_ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type complex128\) to type bool"
|
|
|
|
// old error: "(type untyped bool)"
|
|
_ = string(true) // ERROR "cannot convert true \(type bool\) to type string"
|
|
|
|
_ = string(-1)
|
|
|
|
// old error: "(type untyped number)"
|
|
_ = string(1.0) // ERROR "cannot convert 1 \(type float64\) to type string"
|
|
|
|
// old error: "(type untyped number)"
|
|
_ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(type complex128\) to type string"
|
|
|
|
// old error: "(type untyped string)"
|
|
_ = int("") // ERROR "cannot convert .. \(type string\) to type int"
|
|
|
|
// old error: "(type untyped bool)"
|
|
_ = int(true) // ERROR "cannot convert true \(type bool\) to type int"
|
|
|
|
_ = int(-1)
|
|
_ = int(1)
|
|
_ = int(1.0)
|
|
_ = int(-4 + 2i) // ERROR "truncated to integer"
|
|
|
|
// old error: "(type untyped string)"
|
|
_ = uint("") // ERROR "cannot convert .. \(type string\) to type uint"
|
|
|
|
// old error: "(type untyped bool)"
|
|
_ = uint(true) // ERROR "cannot convert true \(type bool\) to type uint"
|
|
|
|
_ = uint(-1) // ERROR "constant -1 overflows uint"
|
|
_ = uint(1)
|
|
_ = uint(1.0)
|
|
_ = uint(-4 + 2i) // ERROR "constant -4 overflows uint" "truncated to integer"
|
|
|
|
// old error: "(type untyped string)"
|
|
_ = float64("") // ERROR "cannot convert .. \(type string\) to type float64"
|
|
|
|
// old error: "(type untyped bool)"
|
|
_ = float64(true) // ERROR "cannot convert true \(type bool\) to type float64"
|
|
|
|
_ = float64(-1)
|
|
_ = float64(1)
|
|
_ = float64(1.0)
|
|
_ = float64(-4 + 2i) // ERROR "truncated to real"
|
|
|
|
// old error: "(type untyped string)"
|
|
_ = complex128("") // ERROR "cannot convert .. \(type string\) to type complex128"
|
|
|
|
// old error: "(type untyped bool)"
|
|
_ = complex128(true) // ERROR "cannot convert true \(type bool\) to type complex128"
|
|
|
|
_ = complex128(-1)
|
|
_ = complex128(1)
|
|
_ = complex128(1.0)
|
|
}
|