go/test/rename1.go

61 lines
1.1 KiB
Go
Raw Normal View History

// errorcheck
// Copyright 2009 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.
// Verify that renamed identifiers no longer have their old meaning.
// Does not compile.
package main
func main() {
var n byte // ERROR "not a type|expected type"
var y = float32(0) // ERROR "cannot call|expected function"
const (
cmd/compile: rewrite untyped constant conversion logic This CL detangles the hairy mess that was convlit+defaultlit. In particular, it makes the following changes: 1. convlit1 now follows the standard typecheck behavior of setting "n.Type = nil" if there's an error. Notably, this means for a lot of test cases, we now avoid reporting useless follow-on error messages. For example, after reporting that "1 << s + 1.0" has an invalid shift, we no longer also report that it can't be assigned to string. 2. Previously, assignconvfn had some extra logic for trying to suppress errors from convlit/defaultlit so that it could provide its own errors with better context information. Instead, this extra context information is now passed down into convlit1 directly. 3. Relatedly, this CL also removes redundant calls to defaultlit prior to assignconv. As a consequence, when an expression doesn't make sense for a particular assignment (e.g., assigning an untyped string to an integer), the error messages now say "untyped string" instead of just "string". This is more consistent with go/types behavior. 4. defaultlit2 is now smarter about only trying to convert pairs of untyped constants when it's likely to succeed. This allows us to report better error messages for things like 3+"x"; instead of "cannot convert 3 to string" we now report "mismatched types untyped number and untyped string". Passes toolstash-check. Change-Id: I26822a02dc35855bd0ac774907b1cf5737e91882 Reviewed-on: https://go-review.googlesource.com/c/go/+/187657 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-05 20:33:06 +00:00
a = 1 + iota // ERROR "invalid operation|incompatible types"
)
}
const (
append = 1
bool = 2
byte = 3
complex = 4
complex64 = 5
complex128 = 6
cap = 7
close = 8
delete = 9
error = 10
false = 11
float32 = 12
float64 = 13
imag = 14
int = 15
int8 = 16
int16 = 17
int32 = 18
int64 = 19
len = 20
make = 21
new = 22
nil = 23
panic = 24
print = 25
println = 26
real = 27
recover = 28
rune = 29
string = 30
true = 31
uint = 32
uint8 = 33
uint16 = 34
uint32 = 35
uint64 = 36
uintptr = 37
iota = "38"
)