From d738840feab02648899f08d00dc9fcf5f018f6a3 Mon Sep 17 00:00:00 2001 From: Nikita Vasilevsky Date: Sun, 30 Jan 2022 01:42:42 +0000 Subject: [PATCH] Avoid returning nil values from ClassDeclaration#child_nodes --- lib/syntax_tree.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/syntax_tree.rb b/lib/syntax_tree.rb index 6bcf710f..4d76ccac 100644 --- a/lib/syntax_tree.rb +++ b/lib/syntax_tree.rb @@ -3698,7 +3698,11 @@ def initialize(constant:, superclass:, bodystmt:, location:, comments: []) end def child_nodes - [constant, superclass, bodystmt] + [].tap do |nodes| + nodes << constant + nodes << superclass if superclass + nodes << bodystmt + end end def format(q)