1// errorcheck 2 3// Copyright 2010 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 line numbers in error messages. 8// Does not compile. 9 10package main 11 12var ( 13 _ = x // ERROR "undefined.*x" 14 _ = x // ERROR "undefined.*x" 15 _ = x // ERROR "undefined.*x" 16) 17 18type T struct { 19 y int 20} 21 22func foo() *T { return &T{y: 99} } 23func bar() int { return y } // ERROR "undefined.*y" 24 25type T1 struct { 26 y1 int 27} 28 29func foo1() *T1 { return &T1{y1: 99} } 30var y1 = 2 31func bar1() int { return y1 } 32 33func f1(val interface{}) { 34 switch v := val.(type) { 35 default: 36 println(v) 37 } 38} 39 40func f2(val interface{}) { 41 switch val.(type) { 42 default: 43 println(v) // ERROR "undefined.*v" 44 } 45} 46