CoffeeScriptRedux
CoffeeScriptRedux copied to clipboard
Respect syntax error offset location
This makes the syntax error formatter respect the error's offset property. Here is a file demonstrating the difference:
class A
class B
method: ->
console.log('a', 'b',
'c', 'd'
)
Before this change, the error is reported at line 1, column 1. With this change, it is reported correctly on line 6.
I don't understand why the line number was incorrect before. Is there not a simpler way we can fix this? Obviously there's a bug somewhere if it's reporting an error on line 1 for that program.
I was interpreting the error as "while disambiguating a structure that starts at line 1, col 1, I hit an error offset bytes ahead of that point.
I haven't looked into the grammar to know if that's really how it's working, but it seems a reasonable guess.
It might be a bug in pegjs. As far as I know the offset and line/column are supposed to point to the same place.
Yeah, if that's the intent of offset, line, and column then we probably do have a bug in pegjs. Skimming their repo just now it does look like it's supposed to work that way.
We have to remember that we're doing quite a few hacky things to try to get context sensitivity. It could have something to do with either our preprocessor-inserted context markers or the pegcoffee plugin/variant of pegjs we're using.