aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prog/encoding.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/prog/encoding.go b/prog/encoding.go
index 6d7daeacb..cd4eef17f 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -457,7 +457,7 @@ func (p *parser) parseArgImpl(typ Type, dir Dir) (Arg, error) {
return p.parseAuto(typ, dir)
default:
return nil, fmt.Errorf("failed to parse argument at '%c' (line #%v/%v: %v)",
- p.Char(), p.l, p.i, p.s)
+ p.Char(), p.l, p.i, highlightError(p.s, p.i))
}
}
@@ -1261,7 +1261,8 @@ func (p *parser) Ident() string {
func (p *parser) failf(msg string, args ...interface{}) {
if p.e == nil {
- p.e = fmt.Errorf("%v\nline #%v:%v: %v", fmt.Sprintf(msg, args...), p.l, p.i, p.s)
+ p.e = fmt.Errorf("%v\nline #%v:%v: %v", fmt.Sprintf(msg, args...), p.l, p.i,
+ highlightError(p.s, p.i))
}
}
@@ -1311,3 +1312,7 @@ func CallSet(data []byte) (map[string]struct{}, int, error) {
}
return calls, ncalls, nil
}
+
+func highlightError(s string, offset int) string {
+ return s[:offset] + "<<<!!ERROR!!>>>" + s[offset:]
+}