tomland icon indicating copy to clipboard operation
tomland copied to clipboard

[RFC] Track position in file after parsing in TOML AST to produce better error messages

Open chshersh opened this issue 5 years ago • 0 comments

We have two stages for converting TOML to Haskell types:

  1. Parsing
  2. Decoding

Decoding works with a generic TOML representation. But this representation doesn't record the source positions of TOML entries from file. If we can come up with a way to track positions of TOML entries in files, we can improve the quality of error messages and instead of:

tomland decode error:  Type for key name doesn't match.
  Expected: Text
  Actual:   Integer

we can output something like this

tomland decode error:  Type for key name doesn't match.
  Expected: Text
  Actual:   Integer

example.toml
  3 |
  4 | name = 42
  5 | ^^^^^^^^^

chshersh avatar May 18 '20 10:05 chshersh