Skip to content

Commit a0bb8da

Browse files
authored
Merge pull request #72 from bbuchalter/issue-58-disallow-ternary-with-not-node
Disallow turning a conditional into a ternary if there's a Not node without parentheses in the predicate
2 parents 06cc54e + 2a3d9db commit a0bb8da

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/syntax_tree/node.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5115,7 +5115,7 @@ def call(q, node)
51155115
else
51165116
# Otherwise, we're going to check the conditional for certain cases.
51175117
case node
5118-
in predicate: Assign | Command | CommandCall | MAssign | OpAssign
5118+
in predicate: Assign | Command | CommandCall | MAssign | Not | OpAssign
51195119
false
51205120
in {
51215121
statements: { body: [truthy] },

test/fixtures/if.rb

+6
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@
3535
%
3636
if foo {}
3737
end
38+
%
39+
if not a
40+
b
41+
else
42+
c
43+
end

0 commit comments

Comments
 (0)