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

weird loc tracking #161

Closed
KFlash opened this issue Dec 5, 2020 · 4 comments
Closed

weird loc tracking #161

KFlash opened this issue Dec 5, 2020 · 4 comments

Comments

@KFlash
Copy link
Contributor

KFlash commented Dec 5, 2020

@3cp See this test? https://github.com/meriyah/meriyah/blob/master/test/lexer/whitespace.ts#L228

Single line comment shouldn't have any LT - it should break. So shouldn't this test simply have zero LT and hasNext set to true?
Next time you invoke the nextToken it should consume the line terminator.

There are other similar tests too.

https://github.com/meriyah/meriyah/blob/master/test/lexer/whitespace.ts#L641

Here shouldn't the index stop at 5 and not 8?

cc / @fisker What do you think?

@3cp
Copy link
Member

3cp commented Dec 6, 2020

That sounds right. I knew meriyah always put leading space into next token.

What parser issue did this quirk contribute to?

@KFlash
Copy link
Contributor Author

KFlash commented Dec 6, 2020

I just compared Meriyah output against my private code when I noticed this. I don't know about any real world cases except maybe for Prettier?
It also makes it difficult to extract the comment right if you want to extract them by given pos.

@KFlash
Copy link
Contributor Author

KFlash commented Jan 28, 2021

@3cp ideas for an fix?

@3cp
Copy link
Member

3cp commented Aug 17, 2024

The test tests scanned token by skipping comments. It looks fine. I have cleaned up the whitespace unit tests file for some missing check.

@3cp 3cp closed this as completed Aug 17, 2024
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

No branches or pull requests

2 participants