Closed InsertCreativityHere closed 1 year ago
@externl, it looks like rustfmt
got an update recently, because this PR had formatting errors in alot of files I didn't even touch:
https://github.com/icerpc/slicec/actions/runs/5467763283/jobs/9954497252
So just an FYI, I added a configuration option just to get the actions working again so the build for slicec
wouldn't fail, and so they could catch if I'd made any 'real' formatting mistakes: single_line_let_else_max_width = 120
This fixes #603 where the parser will sometimes return over-extendeds span.
What was the problem?
The problem occurs when we try to get the location in between two tokens that can match nothing (an empty string). For example, this is the rule for a struct:
Prelude can match an empty string (you don't have a comment or attribute) and the compact_keyword is optional. So the location in between these two tokens is formally undefined, because they can be matched anywhere.
How was this fixed?
When the grammar is in these situations, it gets 2 locations now:
If the compact keyword is missing it uses
l2
, and if it's present it usesl1
. This ensures that we never try to query the location in between two non-existent tokens.