Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect syntax error offset location #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented May 26, 2015

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.

@ef4 ef4 force-pushed the fix-syntax-error-location branch from 597bf15 to 71c15cb Compare May 26, 2015 00:53
@michaelficarra
Copy link
Owner

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.

@ef4
Copy link
Contributor Author

ef4 commented May 26, 2015

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.

@lydell
Copy link
Collaborator

lydell commented May 26, 2015

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.

@ef4
Copy link
Contributor Author

ef4 commented May 26, 2015

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.

@michaelficarra
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants