diff --git a/lib/yard/parser/ruby/ast_node.rb b/lib/yard/parser/ruby/ast_node.rb index 123ac87db..d539ca309 100644 --- a/lib/yard/parser/ruby/ast_node.rb +++ b/lib/yard/parser/ruby/ast_node.rb @@ -207,9 +207,10 @@ def children # @return [void] def traverse nodes = [self] - nodes.each.with_index do |node, index| + until nodes.empty? + node = nodes.pop yield node - nodes.insert index + 1, *node.children + nodes += node.children.reverse unless node.children.empty? end end