Opened 10 years ago

Closed 8 years ago

#1856 closed feature request (fixed)

Improve error message for mutally recursive modules

Reported by: guest Owned by: simonmar
Priority: normal Milestone: 6.12 branch
Component: Compiler Version: 6.6
Keywords: Modules Recursively Imported Error Messages Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by simonpj)

When I am trying to compile the following modules:

File: Files.hs 

module Files  where
import SecMonad

File: Lattice.hs 

module Lattice where

File: Ref.hs

module Ref where
import SecMonad


File: Screen.hs 

module Screen where
import SecMonad


File: Sec.hs 

module Sec where
import Lattice


File: SecLib.hs  (OBSERVE HERE THAT THE NAME OF THE 
                  MODULE IS NOT THE SAME AS THE FILE)
module SecMonad where
import Lattice
import Sec
import SecMonad
import Files
import Screen
import Ref


File: SecMonad.hs

module SecMonad where

import Lattice
import Sec

I got the message:

ale@localhost ~/Sec7 $ ghci SecLib.hs -fglasgow-exts
GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
[1 of 4] Compiling Lattice          ( Lattice.hs, interpreted )
[2 of 4] Compiling Sec              ( Sec.hs, interpreted )
[3 of 4] Compiling SecIO            ( SecIO.hs, interpreted )
Module imports form a cycle for modules:
  main:Resources imports: Files Lattice
  main:Files imports: SecMonad SecIO Lattice
  main:SecMonad
    imports: Resources Ref Screen Files SecMonad SecIO Sec Lattice
  main:Ref imports: SecMonad SecIO Sec Lattice Data.IORef
  main:Screen imports: SecMonad SecIO Lattice
Failed, modules loaded: SecIO, Lattice, Sec.
*SecIO>

I think that it would be of great help if the compiler can check if the names of the modules match the name of the files. It took me a while to discover the stupid mistake, and I believe that, when you have a large number of mobules, it might be difficult to find this bug. So, a simple check would help a lot in this situation.

That is it!

Attachments (1)

report.tgz (382 bytes) - added by guest 10 years ago.
Modules

Download all attachments as: .zip

Change History (8)

Changed 10 years ago by guest

Attachment: report.tgz added

Modules

comment:1 Changed 10 years ago by simonpj

Description: modified (diff)
difficulty: Unknown

Wiki formatting in description only.

comment:2 Changed 10 years ago by simonpj

Milestone: 6.6.26.8 branch

Good point. Although it's specifically legal to name a file on the command line that contains a module with a different name.

Proposal:

  • Cut down error message to display a minimal cycle
  • Display file names where not same as module name
  • Omit the "main:" stuff

comment:3 Changed 10 years ago by simonmar

Summary: Haskell determines that the modules are recursively imported but they are not, but the problem was the name of a module didn't match the file name where it was holdedImprove error message for mutally recursive modules

comment:4 Changed 9 years ago by igloo

Milestone: 6.8 branch6.10 branch

comment:5 Changed 9 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:6 Changed 8 years ago by simonmar

Owner: set to simonmar

comment:7 Changed 8 years ago by simonmar

Resolution: fixed
Status: newclosed

Done

Wed Sep 16 13:50:36 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * improve the cyclic module error message as per #1856
Note: See TracTickets for help on using tickets.