$ the-wire · showcase
Formatter stops eating comments, protocol consolidation unbreaks
By RepoJournal · Filed · About Elixir & Phoenix · Composed from the cited sources · methodology
Elixir's formatter now preserves comments it used to silently drop and produces the same output on the first pass as the second, while a consolidation crash introduced with the new protocol dispatch path is fixed for beams compiled before it.
Keep comments on do-end block keywords when formatting elixir-lang/elixir
Comments written after a do-end block keyword, as in `rescue # comment` or `else # comment`, were being dropped by `mix format`; they now move to the top of the respective block body instead of vanishing.
Keep formatter output stable for comments after operators elixir-lang/elixir
A comment in front of an operator's right operand, such as `} = conn # comment`, now forces the line break the formatter previously only applied when the source already had a newline there, so the first `mix format` pass yields output that a second run leaves alone.
Fix protocol consolidation crash on beams from older Elixir versions (#15995) elixir-lang/elixir
`Protocol.consolidate/5` began assuming `__select_impl__/1`, `__dispatch_impl__/4`, and `__select_struct__/1` were always defined, so consolidating a protocol beam compiled before that change raised a bare `MatchError` on a reused `_build`. The fix restores consolidation for those older beams.
Return :error when casting malformed datetimes without seconds elixir-ecto/ecto
`Ecto.Type.cast/2` for `:naive_datetime` and `:utc_datetime` and their `_usec` variants raised `FunctionClauseError` on malformed strings shaped like `YYYY-MM-DD HH:MM`, such as `"2015-01-23 ab:50"`, where `to_i/1` produced `nil`s that failed the guards in `Calendar.ISO`. It now returns `:error`, so a form param can no longer crash the cast.
Handle negative years only for datetimes without seconds elixir-ecto/ecto
Negative-year UTC datetimes whose offset crosses a year boundary were coming out years off, because the offset was applied to the positive year before negation; `cast_utc_datetime/1` now handles the sign only where it belongs. Edge case territory, but it was silently wrong rather than an error.