From 74379e5459a0928fca42ec28b991ff61ab530ca6 Mon Sep 17 00:00:00 2001 From: Brian Buchalter Date: Tue, 10 May 2022 11:03:01 -0600 Subject: [PATCH 1/2] Add failing test --- test/fixtures/if.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/fixtures/if.rb b/test/fixtures/if.rb index cabea4c3..607af05d 100644 --- a/test/fixtures/if.rb +++ b/test/fixtures/if.rb @@ -35,3 +35,9 @@ % if foo {} end +% +if not a + b +else + c +end From 2a3d9db5db34ff29adb7843ec0363ed89f516c9b Mon Sep 17 00:00:00 2001 From: Brian Buchalter Date: Tue, 10 May 2022 11:38:47 -0600 Subject: [PATCH 2/2] Disallow turning a conditional into a ternary if there's a Not node without parentheses in the predicate --- lib/syntax_tree/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/syntax_tree/node.rb b/lib/syntax_tree/node.rb index d153ef78..30fd8cf1 100644 --- a/lib/syntax_tree/node.rb +++ b/lib/syntax_tree/node.rb @@ -5192,7 +5192,7 @@ def call(q, node) else # Otherwise, we're going to check the conditional for certain cases. case node - in predicate: Assign | Command | CommandCall | MAssign | OpAssign + in predicate: Assign | Command | CommandCall | MAssign | Not | OpAssign false in { statements: { body: [truthy] },