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

Mark imports as implicit #5

Merged
merged 2 commits into from
Mar 20, 2024
Merged

Mark imports as implicit #5

merged 2 commits into from
Mar 20, 2024

Conversation

tfausak
Copy link
Owner

@tfausak tfausak commented Mar 20, 2024

Consider a simple module like this:

{-# OPTIONS_GHC -Wunused-imports -fplugin=Imp #-}
main = System.IO.print ()

Before the changes in this PR, compiling that module would generate a warning like this:

<no location info>: warning: [GHC-66111] [-Wunused-imports]
    The qualified import of ‘System.IO’ is redundant
      except perhaps to import instances from ‘System.IO’
    To import instances alone, use: import System.IO()

That's not ideal since (a) the import is actually used and (b) the user didn't import the module themselves anyway, so they have no way to fix the warning. By changing it to an implicit import, the warning can be avoided.

Ideally there would be some other way to avoid this warning, but I don't know of any alternative.

@tfausak tfausak added the bug Something isn't working label Mar 20, 2024
@@ -32,31 +32,31 @@ main = Hspec.hspec . Hspec.parallel . Hspec.describe "Imp" $ do
expectImp
[]
"true = Data.Bool.True"
"import qualified Data.Bool\ntrue = Data.Bool.True"
"import (implicit) qualified Data.Bool\ntrue = Data.Bool.True"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that implicit imports are output differently than normal ones. It's a bit weird that they're not even valid syntax, but I suppose that makes sense because they're supposed to be implicit anyway. It also makes the tests a little nicer because I can be sure the imports were actually inserted by Imp (rather than somehow coming from the input or parser).

@tfausak tfausak merged commit 26e519e into main Mar 20, 2024
11 checks passed
@tfausak tfausak deleted the 2024-03-20-implicit branch March 20, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant