[GHC] #13292: panic! (the 'impossible' happened): corePrepPgm

#13292: panic! (the 'impossible' happened): corePrepPgm --------------------------------------+--------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Keywords: | Operating System: Windows Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- It doesn't seem like a serious problem, but I report it anyway. With stack's project template, I just removed `main` and `someFunc`'s type signature and changed `someFunc`'s definition to `return ()`. `stack build` worked well, but `stack repl` emitted this error message. {{{ D:\ghc-corePrepPgm\app\Main.hs:6:1: warning: [-Wdeferred-type-errors] • Couldn't match type ‘ghc-prim-0.5.0.0:GHC.Prim.Any’ with ‘IO’ Expected type: IO () Actual type: ghc-prim-0.5.0.0:GHC.Prim.Any () • In the expression: main When checking the type of the IO action ‘main’ ghc.EXE: panic! (the 'impossible' happened) (GHC version 8.0.2 for x86_64-unknown-mingw32): corePrepPgm [False] cobox_r1bo = typeError @ 'VoidRep @ (Any :: (* -> *)) ~# (IO :: (* -> *)) "D:\\ghc-corePrepPgm\\app\\Main.hs:6:1: error:\n\ \ \\226\\128\\162 Couldn't match type \\226\\128\\152ghc-prim-0.5.0.0:GHC.Prim.Any\\226\\128\\153 with \\226\\128\\152IO\\226\\128\\153\n\ \ Expected type: IO ()\n\ \ Actual type: ghc- prim-0.5.0.0:GHC.Prim.Any ()\n\ \ \\226\\128\\162 In the expression: main\n\ \ When checking the type of the IO action \\226\\128\\152main\\226\\128\\153\n\ \(deferred type error)"# Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: panic! (the 'impossible' happened): corePrepPgm ---------------------------------+-------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by jeiea): * Attachment "ghc-corePrepPgm.7z" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * cc: bgamari (added) * failure: None/Unknown => Other * component: Compiler => Compiler (Type checker) * os: Windows => Unknown/Multiple Comment: Hi, Thanks for the report. I am not sure that this is a bug or at least not a new one. It seems more like a limitation of the type inferencing. The confusing error message comes from the handling of packages in the `cabal` file. The error simplified is: {{{ $ ~/ghc/inplace/bin/ghc-stage2.exe Main.hs [1 of 2] Compiling Lib ( Lib.hs, Lib.o ) Lib.hs:6:12: error: * Ambiguous type variable `m0' arising from a use of `return' prevents the constraint `(Monad m0)' from being solved. Relevant bindings include someFunc :: m0 () (bound at Lib.hs:6:1) Probable fix: use a type annotation to specify what `m0' should be. These potential instances exist: instance Monad IO -- Defined in `GHC.Base' instance Monad Maybe -- Defined in `GHC.Base' instance Monad ((->) r) -- Defined in `GHC.Base' ...plus two others (use -fprint-potential-instances to see them all) * In the expression: return () In an equation for `someFunc': someFunc = return () | 6 | someFunc = return () | ^^^^^^^^^ }}} Essentially (I think) because there's so little context for the type inference it can't disambiguate between the possible types `someFunc` can have. So it can't chose which type is the most general type for `someFunc` simply because they're all valid and can be the most general type. So it needs to be told, either by adding a type signature, or using `someFunc` in a way that allows it to determine what the most general type should be. e.g. {{{ module Lib ( someFunc ) where -- someFunc :: Monad m => m () someFunc = moreFunc moreFunc :: IO () moreFunc = someFunc }}} But I'm not that familiar with GHC's typechecker so I'll reclassify and leave it for someone more knowledgeable in this area. I also don't know why `stack repl` would have worked. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): The issue isn't the warning/error, it's the fact that GHC panicked afterward. It would be helpful to have steps to reproduce that don't involve stack. E.g. `stack repl` is presumably invoking ghci somehow, what command exactly does it run? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jeiea): This is the command which causes the panic. {{{ ghc --interactive -i -isrc -hide-all-packages -package-id=base-4.9.1.0 -- in ghci :add Lib app/Main.hs }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Thanks. `-fdefer-type-errors` is also needed to reproduce (presumably you have this set in a `.ghci` file). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): Oh sorry, I completely missed the panic! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * cc: bgamari (removed) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13292: Type checker rejects ambiguous top level declaration.
-------------------------------------+-------------------------------------
Reporter: jeiea | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.2
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: x86_64
| (amd64)
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#13292: Type checker rejects ambiguous top level declaration. -------------------------------------+------------------------------------- Reporter: jeiea | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: | typecheck/should_fail/T13292 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => typecheck/should_fail/T13292 * resolution: => fixed Comment: Thanks. There was a real bug here. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13292#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC