Fix stack overflow in MethodAttr#documented? on cyclic includes - #1829
Open
SulimanAbdulrazzaq wants to merge 1 commit into
Open
SulimanAbdulrazzaq wants to merge 1 commit into
SulimanAbdulrazzaq wants to merge 1 commit into
Conversation
MethodAttr#documented? also consults the alias and the #see method, and #see is looked up in the ancestors of the method's owner. When the parsed code has modules that include each other (or a superclass cycle), A#m.see is B#m and B#m.see is A#m, so documented? recursed until rdoc stopped with "stack level too deep". Treat a method/attribute that is reached again while it is already being checked as undocumented: the cycle adds no documentation, and every other alias or #see path is still followed. Fixes ruby#1088
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.
MethodAttr#documented?also treats a method as documented when its alias or its#seemethod is documented, and#seeis looked up in the ancestors of the method's owner. With the reproduction from #1088 (comment) (two modules that include each other),A#m.seeisB#mandB#m.seeisA#m, sodocumented?recursed until rdoc stopped with "stack level too deep". A superclass cycle, which #1785 madeancestorshandle, ends in the same loop.The guard stays inside
documented?: a method or attribute that is reached again while it is still being checked counts as undocumented, since the cycle adds no documentation, and every other alias and#seepath is still followed. The flag is only set around the check and is reset in anensure, so a later call gives the same answer.The new tests in
method_attr_test.rbcover cyclic includes with and without a documented method, and a superclass cycle.Fixes #1088