mirror of
https://github.com/golang/go
synced 2024-11-26 20:31:25 -07:00
8f19394b62
Based on https://golang.org/cl/284256 for go/types. Brings this code more in line with go/types. Adjusted various tests to match new error messages which generally are now better: for assignment errors, instead of a generic "cannot convert" we now say "cannot use" followed by a clearer reason as to why not. Major differences to go/types with respect to the changed files: - Some of the new code now returns error codes, but they are only used internally for now, and not reported with errors. - go/types does not "convert" untyped nil values to target types, but here we do. This is unchanged from how types2 handled this before this CL. Change-Id: If45336d7ee679ece100f6d9d9f291a6ea55004d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/302757 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
18 lines
946 B
Go
18 lines
946 B
Go
// errorcheck
|
|
|
|
// Copyright 2017 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.
|
|
|
|
// Issue 11371 (cmd/compile: meaningless error message "truncated to
|
|
// integer")
|
|
|
|
package issue11371
|
|
|
|
const a int = 1.1 // ERROR "constant 1.1 truncated to integer|floating-point constant truncated to integer|truncated to int|truncated"
|
|
const b int = 1e20 // ERROR "overflows int|integer constant overflow|truncated to int|truncated"
|
|
const c int = 1 + 1e-70 // ERROR "constant truncated to integer|truncated to int|truncated"
|
|
const d int = 1 - 1e-70 // ERROR "constant truncated to integer|truncated to int|truncated"
|
|
const e int = 1.00000001 // ERROR "constant truncated to integer|truncated to int|truncated"
|
|
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|floating-point constant truncated to integer|truncated to int|truncated"
|