[GHC] #12906: GHC fails to typecheck Main module without main

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Given a `Main` module without a `main` value, GHC 8 reports the missing `main` and then exits, without bothering to typecheck the rest of the module. Previous versions, I believe, had the more useful behavior of reporting type errors regardless. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): I tried this module using 8.0, 7.10 and 7.8 and they all failed with the same error message: {{{#!haskell module Main where x :: String -> String x s = print (reverse s + 1) }}} {{{
t12906 /home/omer/ghc_bins/ghc-8.0.1/bin/ghc test [1 of 1] Compiling Main ( test.hs, test.o )
test.hs:1:1: error: The IO action ‘main’ is not defined in module ‘Main’
t12906 /home/omer/ghc_bins/ghc-7.10.1/bin/ghc test [1 of 1] Compiling Main ( test.hs, test.o )
test.hs:1:1: The IO action ‘main’ is not defined in module ‘Main’
t12906 /home/omer/ghc_bins/ghc-7.8.1/bin/ghc test [1 of 1] Compiling Main ( test.hs, test.o )
test.hs:1:1: The IO action ‘main’ is not defined in module ‘Main’ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Well, you are right in that GHC //did// use to report more information—you just have to dig back a bit further: {{{ $ /opt/ghc/7.4.2/bin/ghc Bug.hs [1 of 1] Compiling Main ( Bug.hs, Bug.o ) Bug.hs:1:1: The function `main' is not defined in module `Main' Bug.hs:4:7: Couldn't match expected type `String' with actual type `IO ()' In the return type of a call of `print' In the expression: print (reverse s + 1) In an equation for `x': x s = print (reverse s + 1) ryanglscott at T450s-Linux64 in ~/Documents/Hacking/Haskell $ /opt/ghc/7.6.3/bin/ghc Bug.hs [1 of 1] Compiling Main ( Bug.hs, Bug.o ) Bug.hs:1:1: The function `main' is not defined in module `Main' }}} So this happened sometime between GHC 7.4 and 7.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Replying to [comment:2 RyanGlScott]:
Well, you are right in that GHC //did// use to report more information—you just have to dig back a bit further: [...] So this happened sometime between GHC 7.4 and 7.6.
Thanks for the dig! I clearly remembered this all wrong. But my main point is really that whatever the history, it is far more ''useful'' to run the type checker on the module whether or not `main` is found. Requiring a `module` line or a `main` binding just to run the type checker is annoying, and has no apparent benefit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm sure this would be easy to fix, if someone would like to have a go -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: RolandSenn Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: (none) => RolandSenn Comment: I'll ive it a go. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: make test | TEST=T12906 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5338 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * status: new => patch * testcase: => make test TEST=T12906 * differential: => Phab:D5338 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: make test | TEST=T12906 Blocked By: | Blocking: Related Tickets: #15899 | Differential Rev(s): Phab:D5338 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #15899 Comment: See #15899 for a ticket caused by Phab:D5338. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12906: GHC fails to typecheck Main module without main
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: RolandSenn
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case: make test
| TEST=T12906
Blocked By: | Blocking:
Related Tickets: #15899 | Differential Rev(s): Phab:D5338
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#12906: GHC fails to typecheck Main module without main -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: RolandSenn Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: make test | TEST=T12906 Blocked By: | Blocking: Related Tickets: #15899 | Differential Rev(s): Phab:D5338 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12906#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC