File tree 3 files changed +12
-8
lines changed
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -8168,7 +8168,7 @@ def deconstruct_keys(keys)
8168
8168
# not value
8169
8169
#
8170
8170
class Not < Node
8171
- # [untyped] the statement on which to operate
8171
+ # [nil | untyped] the statement on which to operate
8172
8172
attr_reader :statement
8173
8173
8174
8174
# [boolean] whether or not parentheses were used
@@ -8205,7 +8205,7 @@ def deconstruct_keys(keys)
8205
8205
8206
8206
def format ( q )
8207
8207
q . text ( parentheses ? "not(" : "not " )
8208
- q . format ( statement )
8208
+ q . format ( statement ) if statement
8209
8209
q . text ( ")" ) if parentheses
8210
8210
end
8211
8211
end
Original file line number Diff line number Diff line change @@ -2837,19 +2837,17 @@ def on_unary(operator, statement)
2837
2837
# parentheses they don't get reported as a paren node for some reason.
2838
2838
2839
2839
beginning = find_token ( Kw , "not" )
2840
- ending = statement
2840
+ ending = statement || beginning
2841
+ parentheses = source [ beginning . location . end_char ] == "("
2841
2842
2842
- range = beginning . location . end_char ...statement . location . start_char
2843
- paren = source [ range ] . include? ( "(" )
2844
-
2845
- if paren
2843
+ if parentheses
2846
2844
find_token ( LParen )
2847
2845
ending = find_token ( RParen )
2848
2846
end
2849
2847
2850
2848
Not . new (
2851
2849
statement : statement ,
2852
- parentheses : paren ,
2850
+ parentheses : parentheses ,
2853
2851
location : beginning . location . to ( ending . location )
2854
2852
)
2855
2853
else
Original file line number Diff line number Diff line change 1
1
%
2
+ not()
3
+ %
4
+ not ()
5
+ %
2
6
not foo
3
7
%
4
8
not(foo)
9
+ %
10
+ not (foo)
You can’t perform that action at this time.
0 commit comments