You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is planned to deprecate the struct update syntax %MyStruct{x | ...} in a future Elixir release. I asked José if this is a feature they're planning to integrate into mix format --migrate, but it is not likely at the moment.
Since styler also added an automatic rewrite for unless to !if, this would be a nice feature, although it's probably it bit more complicated.
The text was updated successfully, but these errors were encountered:
thanks for bringing this up @SteffenDE!
styler definitely does more than a few deprecation rewrites, so i'm happy to add another. i wouldn't be surprised if formatter itself starts doing more of them though, since they did add the unless => if! rewrite on their end too.
(the following is me thinking out loud, pardon me)
as it'd require backtracking in the ast upon encountering the %Struct{var | ..} syntax to find where var was defined. i don't think there's anywhere equivalent to that in styler's existing behaviours...
anyways, the second change isn't necessary as part of removing the deprecated syntax. but it sure would be nice to do for folks who are concerned about the type warnings that structs provide
Unfortunately I would say that the second part is essential. So if we can't do it automatically, it may be best to ask users to do it. Perhaps what Styler could do is to remove the update syntax IF the variable has been bound to the same struct before. This way, Styler can remove the redundant information, and users are only required to refactor it when it is not redundant?
Relates to: elixir-lang/elixir#13974
It is planned to deprecate the struct update syntax
%MyStruct{x | ...}
in a future Elixir release. I asked José if this is a feature they're planning to integrate intomix format --migrate
, but it is not likely at the moment.Since styler also added an automatic rewrite for unless to !if, this would be a nice feature, although it's probably it bit more complicated.
The text was updated successfully, but these errors were encountered: