Ticket #1856 (closed feature request: fixed)

Opened 6 years ago

Last modified 4 years ago

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: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

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

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

Change History

Changed 6 years ago by guest

Modules

Changed 6 years ago by simonpj

  • difficulty set to Unknown
  • description modified (diff)

Wiki formatting in description only.

Changed 6 years ago by simonpj

  • milestone changed from 6.6.2 to 6.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

Changed 6 years ago by simonmar

  • summary changed from 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 holded to Improve error message for mutally recursive modules

Changed 5 years ago by igloo

  • milestone changed from 6.8 branch to 6.10 branch

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 4 years ago by simonmar

  • owner set to simonmar

Changed 4 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

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.