hasura / kriti-lang

A minimal JSON templating language
Apache License 2.0
56 stars 9 forks source link

Fixes span generation for functions #36

Closed solomon-b closed 2 years ago

solomon-b commented 2 years ago

There is a bug in span generation for functions at the moment:

> parser "{{ escapeUri \"foo\" }}"
Right (EscapeURI (Span {start = AlexSourcePos {line = 0, col = 4}, end = AlexSourcePos {line = 0, col = 13}}) (StringTem (Span {start = AlexSourcePos {line = 0, col = 14}, end = AlexSourcePos {line = 0, col = 19}}) [String (Span {start = AlexSourcePos {line = 0, col = 15}, end = AlexSourcePos {line = 0, col = 18}}) "foo"]))

Notice how the EscapeURI span ends on column 13. It should include the contained StringTem.

This PR fixes the issue:

> parser "{{ escapeUri \"foo\" }}"
Right (EscapeURI (Span {start = AlexSourcePos {line = 0, col = 4}, end = AlexSourcePos {line = 0, col = 19}}) (StringTem (Span {start = AlexSourcePos {line = 0, col = 14}, end = AlexSourcePos {line = 0, col = 19}}) [String (Span {start = AlexSourcePos {line = 0, col = 15}, end = AlexSourcePos {line = 0, col = 18}}) "foo"]))