Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't quite everything, as we want to allow:

if not(a)
  b
else
  c
end

-->

not(a) ? b : c

false
in {
statements: { body: [truthy] },
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/if.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@
%
if foo {}
end
%
Copy link
Contributor Author

@bbuchalter bbuchalter May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised this new fixture doesn't result in a test failure in CI. I get one locally:

  1) Failure:
SyntaxTree::FormattingTest#test_formatted_if_9 [/Users/brian.buchalter/workspace/syntax_tree/test/formatting_test.rb:9]:
--- expected
+++ actual
@@ -1,6 +1,2 @@
-"if not a
-  b
-else
-  c
-end
+"not a ? b : c
 "

if not a
b
else
c
end