[SyntaxTree::ConstRef, NilClass, SyntaxTree::BodyStmt] I wasn't sure about our intentions, but I feel like it might be helpful to expect child_nodes to always return an array of node objects and nothing else so I opened this PR as a discussion with a potential solution. The solution I'm suggesting may look excessive but I end up choosing it versus calling .compact on the resulting array because I liked that we explicitly state which part of the class declaration is optional. Let me know if you have other suggestions! After the change: 3.0.3 :014 > SyntaxTree.parse("class A;end").child_nodes.first.body.first.child_nodes.map(&:class) => [SyntaxTree::ConstRef, SyntaxTree::BodyStmt] If we think that this is a reasonable change to implement, I can quickly change similar nodes like BodyStmt, for example: https://github.com/kddnewton/syntax_tree/blob/d738840feab02648899f08d00dc9fcf5f018f6a3/lib/syntax_tree.rb#L2850 I haven't covered it with tests because wasn't sure if that would be a correct change to do so let me know if I should add some. Thanks!">
Avoid returning nil values from
ClassDeclaration#child_nodes
#16New 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
Uh oh!
There was an error while loading. Please reload this page.
Avoid returning nil values from
ClassDeclaration#child_nodes
#16Changes from all commits
d738840
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing