Fix: empty function call parsing when multiple functions present#328
Merged
rubysolo merged 1 commit intorubysolo:mainfrom Nov 11, 2025
Conversation
Owner
|
❤️ |
|
Thanks for fixing this. Can you please release a new patch version including this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of PR
Fixes a parser bug where consecutive empty function calls (e.g.,
func() + func()) would fail due to incorrect token skipping.Uses token index-based skipping instead of token lookup to prevent conflicts.
Why it broke
Functions with 0 arguments are consumed immediately, requiring the closing bracket to be skipped. Previously, the code searched the token list for
), which would always just find the first instance,3.5.5and prior, it would delete this from the list, which worked fine since than the next closing bracket would become the first.however, with the update to
3.5.6instead of deleting this bracket, it now instead saves its index to be skipped, keeping it still in the same location in the list. This causesfunc1() + func2()to skip the first closing bracket twice.The Fix
Before we do anything, we always check if the
lookaheadis a closing bracket.By doing so, we already confirmed that the next one is a closing backet. So rather than searching the index of this bracket in the list, we can just simply do the current node index + 1
Changes
(For this i removed the tokens list from the arguments, since the only use case was to find this index. and now that that is gone, this list is also not needed there anymore)
Before & After
Before:

After:
0(this is expected. count() with no arguments returns 0)