Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging imports with different names breaks programs #758

Open
jjant opened this issue Dec 23, 2021 · 0 comments
Open

Merging imports with different names breaks programs #758

jjant opened this issue Dec 23, 2021 · 0 comments

Comments

@jjant
Copy link

jjant commented Dec 23, 2021

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_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant