File tree 3 files changed +17
-5
lines changed
3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -4536,6 +4536,7 @@ def deconstruct_keys(keys)
4536
4536
def format ( q )
4537
4537
parts = keywords . map { |( key , value ) | KeywordFormatter . new ( key , value ) }
4538
4538
parts << KeywordRestFormatter . new ( keyword_rest ) if keyword_rest
4539
+
4539
4540
contents = -> do
4540
4541
q . seplist ( parts ) { |part | q . format ( part , stackable : false ) }
4541
4542
end
@@ -4546,8 +4547,9 @@ def format(q)
4546
4547
return
4547
4548
end
4548
4549
4549
- parent = q . parent
4550
- if PATTERNS . include? ( parent . class )
4550
+ if parts . empty?
4551
+ q . text ( "{}" )
4552
+ elsif PATTERNS . include? ( q . parent . class )
4551
4553
q . text ( "{ " )
4552
4554
contents . call
4553
4555
q . text ( " }" )
Original file line number Diff line number Diff line change @@ -1501,13 +1501,19 @@ def on_heredoc_end(value)
1501
1501
# (nil | VarField) keyword_rest
1502
1502
# ) -> HshPtn
1503
1503
def on_hshptn ( constant , keywords , keyword_rest )
1504
- parts = [ constant , keywords , keyword_rest ] . flatten ( 2 ) . compact
1504
+ parts = [ constant , *keywords &.flatten ( 1 ) , keyword_rest ] . compact
1505
+ location =
1506
+ if parts . empty?
1507
+ find_token ( LBrace ) . location . to ( find_token ( RBrace ) . location )
1508
+ else
1509
+ parts [ 0 ] . location . to ( parts [ -1 ] . location )
1510
+ end
1505
1511
1506
1512
HshPtn . new (
1507
1513
constant : constant ,
1508
- keywords : keywords ,
1514
+ keywords : keywords || [ ] ,
1509
1515
keyword_rest : keyword_rest ,
1510
- location : parts [ 0 ] . location . to ( parts [ - 1 ] . location )
1516
+ location : location
1511
1517
)
1512
1518
end
1513
1519
Original file line number Diff line number Diff line change 44
44
case foo
45
45
in Foo[**bar]
46
46
end
47
+ %
48
+ case foo
49
+ in {}
50
+ end
You can’t perform that action at this time.
0 commit comments