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

wrong line in error message #972

Closed
rodneyrehm opened this issue Mar 22, 2015 · 6 comments · Fixed by #979
Closed

wrong line in error message #972

rodneyrehm opened this issue Mar 22, 2015 · 6 comments · Fixed by #979
Assignees
Milestone

Comments

@rodneyrehm
Copy link
Contributor

Considering the following (invalid) input:

$foo: 123px;

.bar {
  width: $bar;
}

bad-token-test

I get the error reported on line 5 (3.2.1-beta.2) and the formatted error message looks as follows:

Error: invalid top-level expression
        on line 5 of stdin
>> }
   -^

3.1.0 reports the error on line 7

@xzyfer xzyfer added this to the 3.2 milestone Mar 23, 2015
@xzyfer
Copy link
Contributor

xzyfer commented Mar 23, 2015

@mgreter any ideas here?

@mgreter
Copy link
Contributor

mgreter commented Mar 23, 2015

Whitespace was not "actively" lexed, so position still points to the position it is reporting. Maybe we should move the parser when an error is thrown (we attach the prefixed whitespace to each lexed token, so we should not just munch away whitespace on it own).

@mgreter mgreter self-assigned this Mar 23, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Mar 23, 2015
@mgreter
Copy link
Contributor

mgreter commented Mar 23, 2015

OK, the actual bug is caused by the way lex works together with the error function in parser.cpp. Normaly when we report errors, it is about the thing we actually lexed. But with this error we actually already lexed the whitespace (and that's why the error "somehow correctly" points there). One easy fix is to set before_token to after_token before calling the error (both are members of the Parser class and contain line/col positions).

@rodneyrehm
Copy link
Contributor Author

Are you sure this is fixed? I'm still getting the wrong line reported…

@mgreter
Copy link
Contributor

mgreter commented Mar 29, 2015

I was pretty sure it was fixed, but it looks you're correct => #1002

@mgreter mgreter reopened this Mar 29, 2015
@mgreter
Copy link
Contributor

mgreter commented Mar 29, 2015

Added a new commit which will hopefully solve it now (8d8dc08)!

@mgreter mgreter closed this as completed Mar 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants