Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Disallow turning a conditional into a ternary if there's a Not node w…
…ithout parentheses in the predicate
  • Loading branch information
bbuchalter committed May 10, 2022
commit 2a3d9db5db34ff29adb7843ec0363ed89f516c9b
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