Opened 10 years ago

Closed 8 years ago

#1792 closed bug (fixed)

-ddump-minimal-imports breaks qualified imports (import...as)

Reported by: guest Owned by:
Priority: low Milestone: 6.12 branch
Component: Compiler Version: 6.6.1
Keywords: Cc: aslatter@…, gwern0@…, fasta
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: T1792_imports
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by simonpj)

When using the -ddump-minimal-imports option on a Haskell file, it breaks qualified imports.

Ie, suppose one has a line in a file thus:

 import qualified Data.ByteString as B (putStr, readFile)

Using -ddump-minimal-imports will give you something like this:

 import Data.ByteString(B.putStr, B.readFile)

There are 3 things wrong here:

  • putStr and readFile should not be renamed thus, as obviously Data.ByteString has nothing under those names
  • Data.ByteString is no longer being imported under a different name, so all function uses relying on B.putStr etc. will break
  • Finally, it's just ugly to have no spaces between the last letter of the module's name and the opening parenthesis.

I see this behavior under GHC 6.6.1, and asl of #haskell tells me he duplicated the import problem using GHCi version 6.8.0.20071019.

-- gwern

Change History (8)

comment:1 Changed 10 years ago by guest

Cc: aslatter@… added

Example program:

module Main where

import System
import qualified Data.ByteString as B

f .>> g = \x -> f x >>= g

main = getArgs >>=
          ((sequence .) $ map (B.readFile .>> B.putStr))

-ddump-minimal-imports produces:

import System(getArgs)
import Data.ByteString(B.putStr, B.readFile)

which should read:

import System(getArgs)
import qualified Data.ByteString as B(B.putStr, B.readFile)

comment:2 Changed 10 years ago by simonpj

Description: modified (diff)
Milestone: 6.10 branch
Priority: normallow

Good point. This is one of those fiddly things, and few people use it. So I'm going to put it as low priority, currently provisionally in the 6.10 queue.

Others: pls yell and add yourselves to the cc list if you use -ddump-minimal-imports.

Simon

comment:3 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:5 Changed 9 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:6 Changed 8 years ago by guest

Cc: gwern0@… added

comment:7 Changed 8 years ago by fasta

Cc: fasta added

comment:8 Changed 8 years ago by igloo

Resolution: fixed
Status: newclosed
Test Case: T1792_imports

Fixed by:

Mon Jul  6 12:25:03 BST 2009  simonpj@microsoft.com
  * Major patch to fix reporting of unused imports
Note: See TracTickets for help on using tickets.