@@ -1411,7 +1411,7 @@ defmodule Code.Formatter do
1411
1411
1412
1412
defp bitstring_segment_to_algebra ( { { :"::" , _ , [ segment , spec ] } , i } , state , last ) do
1413
1413
{ doc , state } = quoted_to_algebra ( segment , :parens_arg , state )
1414
- { spec , state } = bitstring_spec_to_algebra ( spec , state )
1414
+ { spec , state } = bitstring_spec_to_algebra ( spec , state , state . normalize_bitstring_modifiers )
1415
1415
1416
1416
spec = wrap_in_parens_if_inspected_atom ( spec )
1417
1417
spec = if i == last , do: bitstring_wrap_parens ( spec , i , last ) , else: spec
@@ -1430,26 +1430,29 @@ defmodule Code.Formatter do
1430
1430
{ bitstring_wrap_parens ( doc , i , last ) , state }
1431
1431
end
1432
1432
1433
- defp bitstring_spec_to_algebra ( { op , _ , [ left , right ] } , state ) when op in [ :- , :* ] do
1434
- { left , state } = bitstring_spec_to_algebra ( left , state )
1435
- { right , state } = bitstring_spec_element_to_algebra ( right , state )
1433
+ defp bitstring_spec_to_algebra ( { op , _ , [ left , right ] } , state , normalize_modifiers )
1434
+ when op in [ :- , :* ] do
1435
+ normalize_modifiers = normalize_modifiers && op != :*
1436
+ { left , state } = bitstring_spec_to_algebra ( left , state , normalize_modifiers )
1437
+ { right , state } = bitstring_spec_element_to_algebra ( right , state , normalize_modifiers )
1436
1438
{ concat ( concat ( left , Atom . to_string ( op ) ) , right ) , state }
1437
1439
end
1438
1440
1439
- defp bitstring_spec_to_algebra ( spec , state ) do
1440
- bitstring_spec_element_to_algebra ( spec , state )
1441
+ defp bitstring_spec_to_algebra ( spec , state , normalize_modifiers ) do
1442
+ bitstring_spec_element_to_algebra ( spec , state , normalize_modifiers )
1441
1443
end
1442
1444
1443
1445
defp bitstring_spec_element_to_algebra (
1444
1446
{ atom , meta , empty_args } ,
1445
- state = % { normalize_bitstring_modifiers: true }
1447
+ state ,
1448
+ _normalize_modifiers = true
1446
1449
)
1447
1450
when is_atom ( atom ) and empty_args in [ nil , [ ] ] do
1448
1451
empty_args = bitstring_spec_normalize_empty_args ( atom )
1449
1452
quoted_to_algebra_with_parens_if_operator ( { atom , meta , empty_args } , :parens_arg , state )
1450
1453
end
1451
1454
1452
- defp bitstring_spec_element_to_algebra ( spec_element , state ) do
1455
+ defp bitstring_spec_element_to_algebra ( spec_element , state , _normalize_modifiers ) do
1453
1456
quoted_to_algebra_with_parens_if_operator ( spec_element , :parens_arg , state )
1454
1457
end
1455
1458
0 commit comments