2012-02-16 23:48:57 -05:00
|
|
|
// errorcheck
|
2011-10-18 14:55:50 -04:00
|
|
|
|
2016-04-10 14:32:26 -07:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-10-18 14:55:50 -04:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Test that error messages say what the source file says
|
2012-01-17 14:21:50 -08:00
|
|
|
// (uint8 vs byte, int32 vs. rune).
|
2012-02-19 13:19:43 +11:00
|
|
|
// Does not compile.
|
|
|
|
|
|
|
|
package main
|
2011-10-18 14:55:50 -04:00
|
|
|
|
2011-10-26 15:27:47 -07:00
|
|
|
import (
|
|
|
|
"fmt"
|
2011-11-08 15:43:02 -08:00
|
|
|
"unicode/utf8"
|
2011-10-26 15:27:47 -07:00
|
|
|
)
|
|
|
|
|
2011-11-08 15:43:02 -08:00
|
|
|
func f(byte) {}
|
2011-10-18 14:55:50 -04:00
|
|
|
func g(uint8) {}
|
|
|
|
|
|
|
|
func main() {
|
2011-10-26 15:27:47 -07:00
|
|
|
var x float64
|
2011-11-08 15:43:02 -08:00
|
|
|
f(x) // ERROR "byte"
|
|
|
|
g(x) // ERROR "uint8"
|
2011-10-26 15:27:47 -07:00
|
|
|
|
|
|
|
// Test across imports.
|
|
|
|
|
|
|
|
var ff fmt.Formatter
|
|
|
|
var fs fmt.State
|
2011-11-08 15:43:02 -08:00
|
|
|
ff.Format(fs, x) // ERROR "rune"
|
2011-10-26 15:27:47 -07:00
|
|
|
|
2011-11-08 15:43:02 -08:00
|
|
|
utf8.RuneStart(x) // ERROR "byte"
|
2011-10-18 14:55:50 -04:00
|
|
|
}
|