]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't print (empty) package name in errors referring to built-ins
authorRobert Griesemer <gri@golang.org>
Tue, 19 Jan 2016 22:17:29 +0000 (14:17 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 20 Jan 2016 04:43:43 +0000 (04:43 +0000)
Fixes #14010.

Change-Id: Idfd4b063eecf453fe00f3e798099023707a65963
Reviewed-on: https://go-review.googlesource.com/18738
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>

src/cmd/compile/internal/gc/fmt.go
test/fixedbugs/issue14010.go [new file with mode: 0644]

index 4da60f4c89513e1bfa680b11d79cc1033369ea66..64b6e36758d6b58445126bc3f9b9e3360834c383 100644 (file)
@@ -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 (file)
index 0000000..4fdbf76
--- /dev/null
@@ -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"
+}