From: Russ Cox Date: Wed, 16 Sep 2009 23:38:49 +0000 (-0700) Subject: make String work on Position values, to enable X-Git-Tag: weekly.2009-11-06~560 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=127368d220b77f2bfafa7a95cec9b1374f43aa97;p=gostls13.git 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 --- diff --git a/src/pkg/go/token/token.go b/src/pkg/go/token/token.go index e0ee0decf9..1ea6c46e9d 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; }