intlc icon indicating copy to clipboard operation
intlc copied to clipboard

Scoped interpolation type parse errors

Open samhh opened this issue 2 years ago • 0 comments

Not important but I'm trying to learn how to do this in megaparsec.

Here's what a bad type parse error might currently look like:

./file.json:3:21:
  |
3 |     "message": "{x, bad}"
  |                     ^^^^^^
unexpected "bad}"<newline>  }<newline>}<newline>"
expecting "boolean", "date", "number", "plural", "select", "selectordinal", "time", or white space

Ideally the error context stops at the }. At the moment the compared error string appears to be controlled by the longest string in body, which can be observed by removing the selectordinal branch:

./file.json:3:21:
  |
3 |     "message": "{x, bad}"
  |                     ^^^^^^
unexpected "bad}"<newline> "
expecting "boolean", "date", "number", "plural", "select", "time", or white space

When what I really want is:

./file.json:3:21:
  |
3 |     "message": "{x, bad}"
  |                     ^^^
unexpected "bad"
expecting "boolean", "date", "number", "plural", "select", "selectordinal", "time", or white space

samhh avatar May 05 '22 21:05 samhh