Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork61
Commit6e6feaf
committed
Assoc uses Identity formatter if any value is nil
The existing assoc formatter has logic to identify the case where avalue is nil (in a Ruby-3.1 style hash) and preserve the existingformatting. For example: `{ first:, "second" => "value" }` is correctlyleft as-is.However, this logic only worked if the first assoc in thecontainer had the nil value - if a later assoc had a nil value, theIdentity formatter might not be chosen which could cause the formatterto generate invalid Ruby code.As an example, this code: `{ "first" => "value", second: }` would beturned into `{ "first" => "value", :second => }`.This patch pulls the nil value check up to the top of`HashKeyFormatter.for` to ensure it takes precendence over any otherformatting selections. The fixtures have been updated to cover bothcases (nil value in first position, nil value in last position).Fixes#4461 parent8dfae19 commit6e6feaf
2 files changed
+19
-8
lines changedLines changed: 15 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1553 | 1553 |
| |
1554 | 1554 |
| |
1555 | 1555 |
| |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1556 | 1559 |
| |
1557 | 1560 |
| |
1558 | 1561 |
| |
| |||
1784 | 1787 |
| |
1785 | 1788 |
| |
1786 | 1789 |
| |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
1787 | 1802 |
| |
1788 | 1803 |
| |
1789 | 1804 |
| |
1790 |
| - | |
1791 |
| - | |
1792 |
| - | |
1793 |
| - | |
1794 |
| - | |
1795 |
| - | |
1796 |
| - | |
1797 |
| - | |
1798 | 1805 |
| |
1799 | 1806 |
| |
1800 | 1807 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + |
0 commit comments
Comments
(0)