@@ -1419,7 +1419,9 @@ defmodule Code.Formatter do
1419
1419
1420
1420
defp bitstring_segment_to_algebra ( { { :"::" , _ , [ segment , spec ] } , i } , state , last ) do
1421
1421
{ doc , state } = quoted_to_algebra ( segment , :parens_arg , state )
1422
- { spec , state } = bitstring_spec_to_algebra ( spec , state , state . normalize_bitstring_modifiers )
1422
+
1423
+ { spec , state } =
1424
+ bitstring_spec_to_algebra ( spec , state , state . normalize_bitstring_modifiers , :"::" )
1423
1425
1424
1426
spec = wrap_in_parens_if_inspected_atom ( spec )
1425
1427
spec = if i == last , do: bitstring_wrap_parens ( spec , i , last ) , else: spec
@@ -1438,15 +1440,17 @@ defmodule Code.Formatter do
1438
1440
{ bitstring_wrap_parens ( doc , i , last ) , state }
1439
1441
end
1440
1442
1441
- defp bitstring_spec_to_algebra ( { op , _ , [ left , right ] } , state , normalize_modifiers )
1443
+ defp bitstring_spec_to_algebra ( { op , _ , [ left , right ] } , state , normalize_modifiers , paren_op )
1442
1444
when op in [ :- , :* ] do
1443
1445
normalize_modifiers = normalize_modifiers && op != :*
1444
- { left , state } = bitstring_spec_to_algebra ( left , state , normalize_modifiers )
1446
+ { left , state } = bitstring_spec_to_algebra ( left , state , normalize_modifiers , op )
1445
1447
{ right , state } = bitstring_spec_element_to_algebra ( right , state , normalize_modifiers )
1446
- { concat ( concat ( left , Atom . to_string ( op ) ) , right ) , state }
1448
+ doc = concat ( concat ( left , Atom . to_string ( op ) ) , right )
1449
+ doc = if paren_op == :* , do: wrap_in_parens ( doc ) , else: doc
1450
+ { doc , state }
1447
1451
end
1448
1452
1449
- defp bitstring_spec_to_algebra ( spec , state , normalize_modifiers ) do
1453
+ defp bitstring_spec_to_algebra ( spec , state , normalize_modifiers , _paren_op ) do
1450
1454
bitstring_spec_element_to_algebra ( spec , state , normalize_modifiers )
1451
1455
end
1452
1456
0 commit comments