Skip to content

-Wdeferred-type-errors on a program with main not of type IO () yields "main thread exited (uncaught exception)"

My Compiler told me to report this so here you go:

[1 of 1] Compiling Main             ( ghc_bug.hs, interpreted )

ghc_bug.hs:3:1: warning: [-Wdeferred-type-errors]
    * Couldn't match expected type `IO t0' with actual type `() -> ()'
    * Probable cause: `main' is applied to too few arguments
      In the expression: main
      When checking the type of the IO action `main'

ghc_bug.hs:3:8: warning: [-Wdeferred-type-errors]
    * Couldn't match expected type `() -> () -> ()'
                  with actual type `()'
    * The function `()' is applied to one argument,
      but its type `()' has none
      In the expression: () ()
      In an equation for `main': main = () ()
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
        corePrepPgm
  [False] cobox_r1a0 = typeError
                         @ 'VoidRep
                         @ ((() -> ()) :: *) ~# (IO Any :: *)
                         "ghc_bug.hs:3:1: error:\n\
                         \    * Couldn't match expected type `IO t0' with actual type `() -> ()'\n\
                         \    * Probable cause: `main' is applied to too few arguments\n\
                         \      In the expression: main\n\
                         \      When checking the type of the IO action `main'\n\
                         \(deferred type error)"#

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
main :: () -> ()
main = () ()

which that in "ghc_bug.hs" "ghc ghc_bug.hs -fdefer-type-errors -dcore-lint -v" gives me the following:

Glasgow Haskell Compiler, Version 8.0.1, stage 2 booted by GHC version 7.10.3
Using binary package database: /usr/lib/ghc-8.0.1/package.conf.d/package.cache
Using binary package database: /home/harry/.ghc/x86_64-linux-8.0.1/package.conf.d/package.cache
loading package database /usr/lib/ghc-8.0.1/package.conf.d
loading package database /home/harry/.ghc/x86_64-linux-8.0.1/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.11.0.0
wired-in package ghc mapped to ghc-8.0.1
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: 
loading package database /usr/lib/ghc-8.0.1/package.conf.d
loading package database /home/harry/.ghc/x86_64-linux-8.0.1/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.0.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.11.0.0
wired-in package ghc mapped to ghc-8.0.1
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *ghc_bug.hs
!!! Chasing dependencies: finished in 0.42 milliseconds, allocated 0.211 megabytes
Stable obj: []
Stable BCO: []
Ready for upsweep
  [NONREC
      ModSummary {
        ms_hs_date = ****-**-** **:**:**.********** ***
        ms_mod = Main,
        ms_textual_imps = [(Nothing, Prelude)]
        ms_srcimps = []
      }]
*** Deleting temp files:
Deleting: 
compile: input file ghc_bug.hs
*** Checking old interface for Main:
[1 of 1] Compiling Main             ( ghc_bug.hs, ghc_bug.o )
*** Parser [Main]:
!!! Parser [Main]: finished in 0.14 milliseconds, allocated 0.089 megabytes
*** Renamer/typechecker [Main]:
!!! Renamer/typechecker [Main]: finished in 28.70 milliseconds, allocated 14.769 megabytes
*** Desugar [Main]:
Result size of Desugar (after optimization)
  = {terms: 19, types: 52, coercions: 4}
*** Core Linted result of Desugar (after optimization):
*** Core Lint errors : in result of Desugar (after optimization) ***
<no location info>: warning:
    [RHS of cobox_aOD :: ((() -> ()) :: *) ~# (IO Any :: *)]
    The type of this binder is primitive: cobox_aOD
    Binder's type: ((() -> ()) :: *) ~# (IO Any :: *)
*** Offending Program ***
main :: () -> ()
[LclIdX, Str=DmdType]
main =
  case typeError
        @ 'VoidRep
        @ (() :: *) ~# ((() -> () -> ()) :: *)
        "ghc_bug.hs:2:8: error:\n\
        \    * Couldn't match expected type `() -> () -> ()'\n\
        \                  with actual type `()'\n\
        \    * The function `()' is applied to one argument,\n\
        \      but its type `()' has none\n\
        \      In the expression: () ()\n\
        \      In an equation for `main': main = () ()\n\
        \(deferred type error)"#
  of cobox_aOE { __DEFAULT ->
  (()
  `cast` (Sub cobox_aOE :: (() :: *) ~R# ((() -> () -> ()) :: *)))
    ()
  }

$trModule :: Module
[LclIdX, Str=DmdType]
$trModule = Module (TrNameS "main"#) (TrNameS "Main"#)

cobox_aOD :: ((() -> ()) :: *) ~# (IO Any :: *)
[LclId[CoVarId], Str=DmdType]
cobox_aOD =
  typeError
    @ 'VoidRep
    @ ((() -> ()) :: *) ~# (IO Any :: *)
    "ghc_bug.hs:2:1: error:\n\
    \    * Couldn't match expected type `IO t0' with actual type `() -> ()'\n\
    \    * Probable cause: `main' is applied to too few arguments\n\
    \      In the expression: main\n\
    \      When checking the type of the IO action `main'\n\
    \(deferred type error)"#

main :: IO Any
[LclIdX, Str=DmdType]
main =
  runMainIO
    @ Any
    (main
    `cast` (Sub cobox_aOD :: ((() -> ()) :: *) ~R# (IO Any :: *)))

*** End of Offense ***


<no location info>: error: 
Compilation had errors


*** Deleting temp files:
Deleting: 
*** Deleting temp dirs:
Deleting: 
 

and gcc version is: gcc version 7.1.1 20170516 (GCC)

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information