Fix empty SPPF node from xearley ignore carry-over (fixes #1598)#1601
Merged
Conversation
When an item in to_scan was carried over past an ignored sequence with item.node=None (e.g. a prediction at ptr=0 that hasn't matched anything yet), the carry-over still allocated an empty SymbolNode and stored it in node_cache. That empty node later became the left child of a PackedNode when the terminal was finally scanned, and crashed ForestSumVisitor with "max() iterable argument is empty". Skip SymbolNode creation when item.node is None — there's nothing to merge, and new_item.node staying None makes the subsequent PackedNode have left=None, which is well-handled everywhere else.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1601 +/- ##
=======================================
Coverage 90.06% 90.06%
=======================================
Files 52 52
Lines 8089 8095 +6
=======================================
+ Hits 7285 7291 +6
Misses 804 804
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
@chanicpanic Thanks! Btw did you see this PR? I did it on a lark (hah) and I'm not sure it's correct. But the performance gains are substantial. |
Contributor
|
I did see that one. I'm not familiar with the details of Joop Leo, but perhaps it is time for me to learn :) |
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.
When an item in to_scan was carried over past an ignored sequence with item.node=None (e.g. a prediction at ptr=0 that hasn't matched anything yet), the carry-over still allocated an empty SymbolNode and stored it in node_cache. That empty node later became the left child of a PackedNode when the terminal was finally scanned, and crashed ForestSumVisitor with "max() iterable argument is empty".
Skip SymbolNode creation when item.node is None — there's nothing to merge, and new_item.node staying None makes the subsequent PackedNode have left=None, which is well-handled everywhere else.