Merging imports with different names breaks programs
jjant opened this issue · 0 comments
jjant commented
Bug description
Running elm-format on
import Html
import Html as Html_
Results in
import Html as Html_
Which breaks all the Html.x
names. This is even more notable in cases like
import Html as Html1
import Html as Html2
import Html as Html3
import Html as Html_
Where it just keeps the last one.
Proposed solution
Either don't merge aliased imports like these at all, or look at the bindings to check unused aliases and then do it (this is probably needlessly complicated).
Caveat
Note that export lists are always safe to merge, i.e, you can turn this:
import Html as Html1 exposing (a, div)
import Html as Html2 exposing (input)
import Html as Html3
import Html as Html_
Into this (or add a plain import Html exposing (a, div, input)
at the top for consistency):
import Html as Html1 exposing (a, div, input)
import Html as Html2
import Html as Html3
import Html as Html_