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

breaks compile by removing non-redundant imports #445

Open
robx opened this issue Jan 8, 2018 · 4 comments
Open

breaks compile by removing non-redundant imports #445

robx opened this issue Jan 8, 2018 · 4 comments

Comments

@robx
Copy link
Contributor

robx commented Jan 8, 2018

I have imports

import Svg
import Svg.Attributes as Svg
import Svg.Attributes

and access most attributes as Svg.<attribute>. But both Svg and Svg.Attributes define style, so I need the third import to be able to access Svg.Attributes.Style explicitly. elm-format however removes that import statement, converting compiling elm code to non-compiling elm-code.

(Yes, that import situation is a bit messy; it seems that the real Svg.style isn't accessible at all anymore.)

@newmana
Copy link

newmana commented Mar 21, 2018

This took at least a day to debug - as we were accidentally reformatting code in elm-stuff and getting the terrible error message:


The elm-package.json constraints of ‘abadi199/elm-input-extra’ are probably
letting too much stuff through. Definitely open an issue on the relevant github
repo to get this fixed and save other people from this pain.

In the meantime, take a look through the direct dependencies of the broken
package and see if any of them have had releases recently. If you find the new
thing that is causing problems, you can artificially constrain things by adding
some extra constraints to your elm-package.json as a stopgap measure.

Would work on some people's computers and not on others depending on how they'd setup their elm-format (version, directory).

Would suggest an invariant for elm-format is - code compiles -> reformat -> code compiles.

@avh4
Copy link
Owner

avh4 commented Mar 26, 2018

@newmana for reference, can you give the imports your project had that were being collapsed?

@newmana
Copy link

newmana commented Mar 26, 2018

See this pull request (you might have missed that linked above):
abadi199/elm-input-extra#11

Run 0.7.0-exp on:
https://github.com/abadi199/elm-input-extra/blob/1a4116812b0979c63bfbae9e18d960c80bc81bfb/src/Input/Number.elm

Specifically on that file:
import Html.Attributes exposing (style, type_)
import Html.Attributes as Attributes exposing (value)

Becomes:
import Html.Attributes as Attributes exposing (value, style, type_)

Which means Html.Attributes.min/max no longer works.

For example: https://github.com/abadi199/elm-input-extra/blob/1a4116812b0979c63bfbae9e18d960c80bc81bfb/src/Input/Number.elm#L157

@aforemny
Copy link

aforemny commented Aug 1, 2018

(comment deleted, I instead commented on #379)

Viir added a commit to pine-vm/pine that referenced this issue Sep 13, 2021
Adapt the expectations in automated tests, considering that some modules import the same module using different aliases.
The previous version was closer to behavior as observed with elm-format. However, looking closer at imports, the current version of elm-format seems to be not always compatible with Elm, sometimes breaking compiling code. For discussion of the issues around import statements, see:
avh4/elm-format#379 (comment)
avh4/elm-format#445
avh4/elm-format#577
Viir added a commit to pine-vm/pine that referenced this issue Sep 13, 2021
Adapt the expectations in automated tests, considering that some modules import the same module using different aliases.
The previous version was closer to behavior as observed with elm-format. However, looking closer at imports, the current version of elm-format seems to be not always compatible with Elm, sometimes breaking compiling code. For discussion of the issues around import statements, see:
avh4/elm-format#379 (comment)
avh4/elm-format#445
avh4/elm-format#577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants