mvdan/gogrep

syntax errors report wrong position information

rogpeppe opened this issue · 3 comments

When gogrep reports a syntax error in the match expression, it uses the wrong
position information because it reports the positions after $ substitutions have been made.

mvdan commented

Can you give a short example?

For example:

% gogrep 'print($x, }'
cannot parse expr: 1:21: expected operand, found '}' (and 1 more errors)

Column 21 is beyond the end of the expression we passed in.

mvdan commented

This is a bit tricky - we currently have logic to offset the templates, but this will require subtractions at certain line and column positions.