apollo-rs icon indicating copy to clipboard operation
apollo-rs copied to clipboard

Incorrect spans after a lexer error

Open goto-bus-stop opened this issue 2 years ago • 0 comments

Related to #325 and #446

If we have some input with completely invalid characters, for example:

type A {
<<<<<<
  field(arg1: Int): String
======
  field(arg1: Boolean): String
>>>>>>
}

< is not a token in any circumstance, so the lexer emits an error. The parser picks up this error and re-emits it, but it does not account for the error token in the parse tree. So, like in #446, lexer errors cause misaligned spans for any nodes that come after.

This could probably be addressed similarly to #446, by propagating lexer errors into the tree with the ERROR syntax node kind.

goto-bus-stop avatar Feb 08 '23 09:02 goto-bus-stop