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

fix: advance past comments in raw go expressions #871

Merged
merged 4 commits into from
Aug 18, 2024

Conversation

knudtty
Copy link
Contributor

@knudtty knudtty commented Aug 3, 2024

Fixes #870

When looking into the internal go/scanner package, I found the final comments are skipped. It works by scanning til the end of a comment, then a goto to the beginning of the Scan function if the mode is not set to ScanComments. If the scanner encounters the final closing brace, the position returned has not advanced.

I implemented a solution that scans comments and advances the length of the token literal. While writing this description I realized the end variable in the go expression extractor probably just needs to be updated properly. Essentially I have implemented 2 fixes. Please review both (small) commits, in case one is a better solution than the other.

@knudtty knudtty force-pushed the rawgo-comment-parse branch from efe4e5f to b7b5268 Compare August 3, 2024 03:15
@a-h
Copy link
Owner

a-h commented Aug 18, 2024

Did you run the tests? I'm getting an error with this PR. There's also no test case to check the new behaviour.

@a-h
Copy link
Owner

a-h commented Aug 18, 2024

I've updated the PR to the test case you provided in the issue, and the first commit in this PR.

Thanks!

@a-h a-h merged commit 211912f into a-h:main Aug 18, 2024
4 checks passed
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.

Raw go errors if block ends with a comment
2 participants