Commit 127368d2 authored by Russ Cox's avatar Russ Cox

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
parent d5be41fc
...@@ -352,8 +352,7 @@ func (pos *Position) IsValid() bool { ...@@ -352,8 +352,7 @@ func (pos *Position) IsValid() bool {
} }
func (pos *Position) String() string { func (pos Position) String() string {
if pos != nil {
s := pos.Filename; s := pos.Filename;
if pos.IsValid() { if pos.IsValid() {
if s != "" { if s != "" {
...@@ -361,9 +360,8 @@ func (pos *Position) String() string { ...@@ -361,9 +360,8 @@ func (pos *Position) String() string {
} }
s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); s += fmt.Sprintf("%d:%d", pos.Line, pos.Column);
} }
if s != "" { if s == "" {
return s; s = "???";
} }
} return s;
return "<unknown position>";
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment