From d224dc22ccd2535564635449d63d44a2af8d3aee Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 1 Apr 2022 11:34:01 -0400 Subject: [PATCH] Allow passing `nil` to `visit` Signed-off-by: Alexandre Terrasa --- lib/syntax_tree/visitor.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/syntax_tree/visitor.rb b/lib/syntax_tree/visitor.rb index ddab8f0a..87e6ef76 100644 --- a/lib/syntax_tree/visitor.rb +++ b/lib/syntax_tree/visitor.rb @@ -54,11 +54,11 @@ def visit_methods end def visit(node) - node.accept(self) + node&.accept(self) end def visit_child_nodes(node) - node.child_nodes.each { |child_node| visit(child_node) if child_node } + node.child_nodes.each { |child_node| visit(child_node) } end # Visit an ARef node.