diff options
| author | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-22 19:15:03 +0900 |
|---|---|---|
| committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-22 19:15:03 +0900 |
| commit | 02674d7264aea363a8f7b7839ab77ce64ba720db (patch) | |
| tree | a849d566004b7d1e711fa4c667a54a5eab322c78 /error | |
| parent | Support %left and %right to specify precedences and associativities (diff) | |
| download | urubu-02674d7264aea363a8f7b7839ab77ce64ba720db.tar.gz urubu-02674d7264aea363a8f7b7839ab77ce64ba720db.tar.xz | |
Add a column number to an error message
Diffstat (limited to 'error')
| -rw-r--r-- | error/error.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/error/error.go b/error/error.go index 1781f2a..0e5d3af 100644 --- a/error/error.go +++ b/error/error.go @@ -39,6 +39,7 @@ type SpecError struct { FilePath string SourceName string Row int + Col int } func (e *SpecError) Error() string { @@ -46,8 +47,8 @@ func (e *SpecError) Error() string { if e.SourceName != "" { fmt.Fprintf(&b, "%v: ", e.SourceName) } - if e.Row != 0 { - fmt.Fprintf(&b, "%v: ", e.Row) + if e.Row != 0 && e.Col != 0 { + fmt.Fprintf(&b, "%v:%v: ", e.Row, e.Col) } fmt.Fprintf(&b, "error: %v", e.Cause) if e.Detail != "" { |
