Opened 2 years ago

Closed 2 years ago

#6007 closed bug (fixed)

ghci: Importing specific non-existent names from a module breaks later imports

Reported by: josh Owned by: simonmar
Priority: normal Milestone: 7.4.2
Component: GHCi Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

At the ghci prompt, attempting to import specific non-existent names from a module breaks any future import attempts, causing them to fail with the same error message that the original import failed with (in addition to any error message they generate themselves). For example:

Prelude> import System.IO(foo)

<interactive>:1:18: Module `System.IO' does not export `foo'
Prelude> import Control.Monad.Error

<interactive>:1:18: Module `System.IO' does not export `foo'

Or compounding the problem:

Prelude> import System.IO(foo)

<interactive>:1:18: Module `System.IO' does not export `foo'
Prelude> import Control.Monad.Error(foo)

<interactive>:1:18: Module `System.IO' does not export `foo'

<interactive>:1:28:
    Module `Control.Monad.Error' does not export `foo'
Prelude> import Control.Monad.Error

<interactive>:1:18: Module `System.IO' does not export `foo'

Change History (4)

comment:1 Changed 2 years ago by simonmar

  • Component changed from Compiler to GHCi
  • Difficulty set to Unknown
  • Milestone set to 7.6.1
  • Owner set to simonmar

Yes, this is a bit unfortunate. You can see what happens with :show imports:

Prelude> import System.IO(foo)

<interactive>:1:18: Module `System.IO' does not export `foo'
Prelude> :show imports
import Prelude -- implicit
import System.IO ( foo )
Prelude> 

The import is remembered by GHCi and replayed every time the set of imports changes. We do catch obvious problems such as when the module does not exist, but not deeper errors like this.

You can recover with :module -System.IO:

Prelude> :module -System.IO
Prelude> :show imports
import Prelude -- implicit
Prelude> 

I shall look into how to fix this, but I think it needs a significant restructuring.

comment:2 Changed 2 years ago by marlowsd@…

commit b6e28266cf29bfdf07fe08e894df77b400da8a04

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Fri Apr 27 13:07:50 2012 +0100

    Catch illegal imports earlier (#6007)

 ghc/InteractiveUI.hs |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

comment:3 Changed 2 years ago by simonmar

  • Milestone changed from 7.6.1 to 7.4.2
  • Status changed from new to merge

comment:4 Changed 2 years ago by pcapriotti

  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.