Ticket #7187 (closed bug: invalid)

Opened 9 months ago

Last modified 9 months ago

-main-is silently failes to create executable when no main is found.

Reported by: timthelion Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

[timothy@timothy main-is]$ cat Foo.hs 
module Foo where
main = print "foooballls"
[timothy@timothy main-is]$ ghc Foo.hs 
[1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
[timothy@timothy main-is]$ ls
Foo.hi  Foo.hs  Foo.o
[timothy@timothy main-is]$ ghc Foo.hs -main-is GeorgeWashington
[timothy@timothy main-is]$ ls
Foo.hi  Foo.hs  Foo.o
[timothy@timothy main-is]$ ghc Foo.hs -main-is Foo
[1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
Linking Foo ...
[timothy@timothy main-is]$ 
There should be a warning when I try to compile with -main-is as GeorgeWashington.  Just for us bad spellers :D

$ ghc -v
Glasgow Haskell Compiler, Version 7.4.2, stage 2 booted by GHC version 7.4.1
--clip--

Change History

Changed 9 months ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

Suppose you say

ghc Foo.hs

Then

  • If Foo.hs does not say module Main where..., GHC will happily compile it to Foo.o and stop.
  • But if Foo.hs does say module Main where..., then GHC will compile, and then link, making Foo.exe.

Now, if you say -mainIs GeorgeWashington, GHC behaves exactly as above, but instead of looking for module Main where.. it looks for module GeorgeWashington where... See the documentation for -main-is.

So that's why you are getting this behaviour: currently it's by design.

By all means suggest some alternative design and open a feature request. But I'll close this bug report. (Reopen if I have misunderstood.)

Simon

Note: See TracTickets for help on using tickets.