From 53958468907a349662bf49d349e1c63bea25861f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 19 Jan 2016 14:17:29 -0800 Subject: [PATCH] cmd/compile: don't print (empty) package name in errors referring to built-ins Fixes #14010. Change-Id: Idfd4b063eecf453fe00f3e798099023707a65963 Reviewed-on: https://go-review.googlesource.com/18738 Reviewed-by: Russ Cox Run-TryBot: Robert Griesemer --- src/cmd/compile/internal/gc/fmt.go | 2 +- test/fixedbugs/issue14010.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue14010.go diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go index 4da60f4c89..64b6e36758 100644 --- a/src/cmd/compile/internal/gc/fmt.go +++ b/src/cmd/compile/internal/gc/fmt.go @@ -419,7 +419,7 @@ func symfmt(s *Sym, flag int) string { if s.Pkg != nil && flag&obj.FmtShort == 0 { switch fmtmode { case FErr: // This is for the user - if s.Pkg == localpkg { + if s.Pkg == builtinpkg || s.Pkg == localpkg { return s.Name } diff --git a/test/fixedbugs/issue14010.go b/test/fixedbugs/issue14010.go new file mode 100644 index 0000000000..4fdbf76b90 --- /dev/null +++ b/test/fixedbugs/issue14010.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 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 built-in types don't get printed with +// (empty) package qualification. + +package main + +func main() { + true = false // ERROR "cannot assign to true" + byte = 0 // ERROR "not an expression" "cannot assign to byte" +} -- 2.48.1