modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/alias.go (about)

     1  // errorcheck
     2  
     3  // Copyright 2011 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test that error messages say what the source file says
     8  // (uint8 vs byte, int32 vs. rune).
     9  // Does not compile.
    10  
    11  package main
    12  
    13  import (
    14  	"fmt"
    15  	"unicode/utf8"
    16  )
    17  
    18  func f(byte)  {}
    19  func g(uint8) {}
    20  
    21  func main() {
    22  	var x float64
    23  	f(x) // ERROR "byte"
    24  	g(x) // ERROR "uint8"
    25  
    26  	// Test across imports.
    27  
    28  	var ff fmt.Formatter
    29  	var fs fmt.State
    30  	ff.Format(fs, x) // ERROR "rune"
    31  
    32  	utf8.RuneStart(x) // ERROR "byte"
    33  }