From 46d2fbf4fefb2542d3f7f3ae73c1b301e95e8696 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Fri, 22 Jul 2022 13:09:32 -0400 Subject: [PATCH] Properly handle conditionals in assignment --- lib/syntax_tree/node.rb | 2 +- test/fixtures/if.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/syntax_tree/node.rb b/lib/syntax_tree/node.rb index 58335b00..b633a1c9 100644 --- a/lib/syntax_tree/node.rb +++ b/lib/syntax_tree/node.rb @@ -5173,7 +5173,7 @@ def self.call(parent) while (node = queue.shift) return true if [Assign, MAssign, OpAssign].include?(node.class) - queue += node.child_nodes + queue += node.child_nodes.compact end false diff --git a/test/fixtures/if.rb b/test/fixtures/if.rb index e5e88103..1963d301 100644 --- a/test/fixtures/if.rb +++ b/test/fixtures/if.rb @@ -59,3 +59,7 @@ baz end ) +% +if (x = x + 1).to_i + x +end