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: missing flag from regex literal in corner case #529

Merged
merged 1 commit into from
Jul 9, 2024
Merged

fix: missing flag from regex literal in corner case #529

merged 1 commit into from
Jul 9, 2024

Conversation

psve
Copy link
Contributor

@psve psve commented Jul 5, 2024

In the specific corner case where a regex contains a flag but is not followed by any symbols, the ast.RegExpLiteral.Literal value would drop (part of) that flag.

This happens because the p.next() call during the parsing of the flag wouldn't actually advance the p.chrOffset, and thus endOffset would be erroneously adjusted.

The fix is just to use the current p.chrOffset and then call p.next() afterwards.

@stevenh stevenh changed the title Fix missing flag from regex literal in corner case fix: missing flag from regex literal in corner case Jul 5, 2024
In the specific corner case where a regex contains a flag but is not
followed by any symbols, the ast.RegExpLiteral.Literal value would drop
(part of) that flag.

This happens because the p.next() call during the parsing of the flag
wouldn't actually advance the p.chrOffset, and thus endOffset would be
erroneously adjusted.

The fix is just to use the current p.chrOffset and then call p.next()
afterwards.
@psve
Copy link
Contributor Author

psve commented Jul 8, 2024

@stevenh , I removed the erroneous import, the linter checks should pass now.

@stevenh stevenh merged commit a39e65d into robertkrimen:master Jul 9, 2024
2 checks passed
@stevenh
Copy link
Collaborator

stevenh commented Jul 9, 2024

Thanks for the PR @psve 🥇

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.

2 participants