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,18 +352,16 @@ func (pos *Position) IsValid() bool { ...@@ -352,18 +352,16 @@ 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 != "" {
s += ":";
}
s += fmt.Sprintf("%d:%d", pos.Line, pos.Column);
}
if s != "" { if s != "" {
return s; s += ":";
} }
s += fmt.Sprintf("%d:%d", pos.Line, pos.Column);
}
if s == "" {
s = "???";
} }
return "<unknown position>"; return s;
} }
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