diff options
author | Robert Griesemer <gri@golang.org> | 2009-07-30 19:39:47 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-07-30 19:39:47 -0700 |
commit | dabb97986841f70cd9d71444060b677d98e6f302 (patch) | |
tree | 4e83dc1ac1294f6917378602d5112ac67af1978d /src/pkg/go | |
parent | c56ea4eaffb284100a5fda37d4322c328af0e419 (diff) | |
download | golang-dabb97986841f70cd9d71444060b677d98e6f302.tar.gz |
- don't call String method of AST nodes when converting them to text
- make token.Position.String more robust
TBR=rsc
DELTA=20 (10 added, 6 deleted, 4 changed)
OCL=32564
CL=32564
Diffstat (limited to 'src/pkg/go')
-rw-r--r-- | src/pkg/go/token/token.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pkg/go/token/token.go b/src/pkg/go/token/token.go index 61a0c622c..32958b53f 100644 --- a/src/pkg/go/token/token.go +++ b/src/pkg/go/token/token.go @@ -353,15 +353,17 @@ func (pos *Position) IsValid() bool { func (pos *Position) String() string { - s := pos.Filename; - if pos.IsValid() { + if pos != nil { + s := pos.Filename; + if pos.IsValid() { + if s != "" { + s += ":"; + } + s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); + } if s != "" { - s += ":"; + return s; } - s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); - } - if s != "" { - return s; } return "<unknown position>"; } |