-
Notifications
You must be signed in to change notification settings - Fork 46
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
Incorrect Line Numbers Reported #37
Comments
@KFlash I implemented this fix, and it still reports the incorrect line number (note that the column is correct, being the |
I've found the problem. My file was saved using CRLF line breaks. When this is done, all line numbers are out, but not by the number of lines up until that point. So under some, but not all, conditions |
I'm not sure what's going on, but for every newline the line count is increased. That's normal. See here. And for Your line 109 |
@KFlash : Line 109 was a typo, and should've been It's definitely not counting lines correctly if the file uses CRLF line-endings; I can switch between CRLF and LF and see that with the former the line number is consistently out, reporting 121 instead of 109 and with the latter it reports 109. I can go back and forth with the only variable being the file's line endings. I've done this with multiple files and multiple classes of errors. With your fix implemented the same (incorrect) line number was still reported, hence it was not that the line number passed down shouldn't be used. And the problem was not limited to handling With further digging I discovered that the line numbers associated with all parsed elements were incorrect when CRLF line-endings are used. It was a sheer fluke/inspiration that I noticed the CRLF line endings and thought to try changing it, and that only because I normally use LF. |
@lawrence-dol Still not sure what's going on here. I just ran a bunch of tests against Acorn and got the exact same results. |
As an aside the bit manipulation Lastly, and I didn't look at this closely, but on principle a CRLF should be consumed as a whole, so when an LF is processed, it should unconditionally clear bit 3 ( |
@KFlash : I believe the test you referenced is invalid for this case, because it doesn't replicate the conditions required to trip the fault, which will be a specific sequence of CRLF. I will attempt to reproduce them, |
The problem lies with single line comments. The line is out by one for every preceding SLC, whether or not they are on a line by themselves or after some code. Simplest replication:
Alter the number of comments and the reported line changes. |
I'm working on it. Try to see if you see any differences with 1.6.12. I just pushed it to NPM. |
1.6.13 seems to have resolved the problem. |
Good to know :) |
Thanks for working with me on this. Apologies for the misleading bit about |
No problem. Issue was very easy, and the way you investigated and described things was very helpful :) |
I am using Meriyah with GraalVM to validate Javascript source in my code editor. I am using the version from the
dev
branch from commit 96eb15f, dated 2019-08-21.Given the code:
The line reported from Meriyah for the error is:
Which was immensely difficult to figure out.
After a long time I noticed the missing
=
at line 109. Then I used the browser to locate the error and it pointed to thethis
at line 109 also. Obviously this was made much more difficult by the fact that there was no reason to suspect the line number was incorrect. Since I've been using Meriyah for a while, I suspect that this was introduced in the last few weeks.The text was updated successfully, but these errors were encountered: