Initialize default traversal state when component enumerators run - #36
Open
OskarEichler wants to merge 1 commit into
Open
Initialize default traversal state when component enumerators run#36OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
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.
Summary
Create default traversal state when a component-from-node enumerator runs, so it can be enumerated again or rewound. Preserve explicitly supplied state objects for callers that intentionally share traversal state.
Reproduction
The default hash and stack are currently created before
to_enumand captured in its arguments. Later enumerations reuse visited-node state. Deferring allocation until the block path makes implicit state fresh on each run. The mixin entry point gets the same correction.Verification
Ruby 4.0.6 through rbenv:
to_a,nextthenrewind,takethen complete enumeration, and explicit shared state.git diff --checkpass. No dependency or version changes.No tests were added/modified under the requesting project's policy; repros are external. Local verification covers macOS/Ruby 4.0.6, not the full upstream matrix. Explicitly supplied state remains caller-owned and can intentionally affect subsequent enumerations.
Breaking-change notes
Repeated enumeration with implicit state now repeats the complete traversal instead of silently omitting previously visited children. Explicit state behavior is preserved. Passing nil for either optional state argument now selects a fresh default instead of failing incidentally. Cycle/self-loop semantics and traversal ordering are unchanged.