From 3cea70516722c910d12fd28cbeb4aabb9d2873df Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 16 Sep 2009 16:38:49 -0700 Subject: make String work on Position values, to enable fmt.Printf("%s: %s\n", expr.Pos(), message); R=gri DELTA=15 (1 added, 3 deleted, 11 changed) OCL=34706 CL=34708 --- src/pkg/go/token/token.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pkg/go/token/token.go b/src/pkg/go/token/token.go index e0ee0decf..1ea6c46e9 100644 --- a/src/pkg/go/token/token.go +++ b/src/pkg/go/token/token.go @@ -352,18 +352,16 @@ func (pos *Position) IsValid() bool { } -func (pos *Position) String() string { - if pos != nil { - s := pos.Filename; - if pos.IsValid() { - if s != "" { - s += ":"; - } - s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); - } +func (pos Position) String() string { + s := pos.Filename; + if pos.IsValid() { if s != "" { - return s; + s += ":"; } + s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); + } + if s == "" { + s = "???"; } - return ""; + return s; } -- cgit v1.2.3