Ticket #2428 (closed bug: wontfix)

Opened 5 years ago

Last modified 3 years ago

bad error message for multiple modules in the same file

Reported by: Isaac Dupree Owned by:
Priority: low Milestone: 7.0.1
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

consider this file:

module MyMod where
foo :: Int
foo = 3

module Main (main) where
import MyMod (foo)
main :: IO ()
main = print foo

The layout rule dictates that this parses properly (the first module clause ends when the second "module" gives a parse error, just like "in" ends a "let"); this gets the same error:

module MyMod where
 { foo :: Int; foo = 3 }
module Main (main) where
 { import MyMod (foo); main :: IO (); main = print foo }

The Haskell98 report doesn't say anything about how modules are expected to be laid out in files, so I had assumed it would work. The error is

parse error on input `module'

(except if Main comes before MyMod, and --make is used with ghc, we get

Could not find module `MyMod':
Use -v to see a list of the files searched for.

even though MyMod is clearly (to a human) in that very file.)

It took me a long time to figure out what was wrong and what I had to do. Admittedly I'm only slightly interested in GHC implementing support to allow this, since if multiple files are involved at all it causes module-finding trouble (obviously to me now); mostly I just want a good error message, maybe something like "Each file must contain exactly one module. Any module intended to be imported must be in an appropriately named file, e.g. module Module.Name' goes in Module/Name.hs'."

( This happened to me a long time ago... but I was reminded by #2427 )

Change History

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • milestone set to 6.10 branch

Thanks for the suggestion

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to wontfix

It's tricky to fix the

Could not find module `MyMod':

error, as GHC is deliberately not parsing the entire module for efficiency reasons.

As this ticket hasn't gathered any other supporters in 2 years, I think I'll just mark it wontfix.

Note: See TracTickets for help on using tickets.