[GHC] #12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole"
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: TypeFamilies, | Operating System: MacOS X CustomTypeErrors | Architecture: x86_64 | Type of failure: Compile-time (amd64) | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If I create a type family – open or closed – with a case that evaluates to a `TypeError`, and define a top-level binding with this type, loading the file with `-fdefer-type-errors` enabled (or via `:load!`/`:reload!`) panics GHC with "opt_univ fell into a hole". (And if I used `:load!` or `:reload!`, `-fdefer-type-errors` doesn't get unset.) A minimal example: {{{#!hs {-# LANGUAGE TypeFamilies, DataKinds, UndecidableInstances #-} import GHC.TypeLits type family F a where F a = TypeError (Text "error") err :: F () err = () }}} results in the panic {{{ ….hs:9:7: warning: [-Wdeferred-type-errors] • error • In the expression: () In an equation for ‘err’: err = () ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-apple-darwin): opt_univ fell into a hole {a4Va} }}} Adding more cases to the type family, or making it open, still cause the crash. This holds whether the error case is a final catch-all case, or something more like {{{#!hs type family F a where F () = TypeError (Text "error") F a = () }}} Just using a type synonym for `F` doesn't cause a panic, however, and nor does giving `err` the type `TypeError (Text "error")` directly. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: TypeFamilies, | CustomTypeErrors Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by antalsz): * Attachment "type-families-TypeError-defer-type-errors-opt_univ-bug.hs" added. The minimal example contained in the text of the ticket -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: TypeFamilies, | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * priority: normal => high * os: MacOS X => Unknown/Multiple * architecture: x86_64 (amd64) => Unknown/Multiple @@ -11,0 +11,2 @@ + + module T12104 where New description: If I create a type family – open or closed – with a case that evaluates to a `TypeError`, and define a top-level binding with this type, loading the file with `-fdefer-type-errors` enabled (or via `:load!`/`:reload!`) panics GHC with "opt_univ fell into a hole". (And if I used `:load!` or `:reload!`, `-fdefer-type-errors` doesn't get unset.) A minimal example: {{{#!hs {-# LANGUAGE TypeFamilies, DataKinds, UndecidableInstances #-} module T12104 where import GHC.TypeLits type family F a where F a = TypeError (Text "error") err :: F () err = () }}} results in the panic {{{ ….hs:9:7: warning: [-Wdeferred-type-errors] • error • In the expression: () In an equation for ‘err’: err = () ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-apple-darwin): opt_univ fell into a hole {a4Va} }}} Adding more cases to the type family, or making it open, still cause the crash. This holds whether the error case is a final catch-all case, or something more like {{{#!hs type family F a where F () = TypeError (Text "error") F a = () }}} Just using a type synonym for `F` doesn't cause a panic, however, and nor does giving `err` the type `TypeError (Text "error")` directly. -- Comment: Confirmed with HEAD (8.1.20160520). Also reproducible by running just {{{ ghc -fdefer-type-errors type-families-TypeError-defer-type-errors- opt_univ-bug.hs }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * cc: conal (added) * component: Compiler => Compiler (Type checker) Comment: Conal Elliott reported the same panic in https://mail.haskell.org/pipermail/ghc-devs/2016-April/011687.html, when writing a custom GHC plugin. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by kosmikus): * cc: kosmikus (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by kosmikus): This is a problem for me as well, in https://github.com/kosmikus/records- sop/blob/13e3f76b511fd11f7e3b120d696a0a136cccb2fb/tests/Examples.hs#L163-L172 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Works ok in HEAD. I don't have an 8.2 branch to hand to check. Can someone add this as a regression test, pls? Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by kosmikus): Simon, thanks a lot for testing with HEAD. I can confirm that my code works with HEAD (8.3.20170422) as well, but it still crashes with 8.2.0.20170422. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Could be the fix to #12156 (unlikely), or #13381 (more likely), or #13487. I'm not sure which of these are merged. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I've confirmed that 2f9f1f86849ebc18af409c9b3fd809c9cd464021 (the fix for #13487) fixes this program as well. Curiously, #13487 was marked as merge, but hasn't made it into 8.2 for some reason. Can we do so? I'll prepare a regression test. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #13487 | Differential Rev(s): Phab:D3495 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3495 * related: => #13487 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #13487 | Differential Rev(s): Phab:D3495 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"69b9b853e3e68191cdfa8aec0e4da966298a2659/ghc" 69b9b853/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="69b9b853e3e68191cdfa8aec0e4da966298a2659" Add regression test for #12104 Commit 2f9f1f86849ebc18af409c9b3fd809c9cd464021 (#13487) fixes #12104 as well. This adds a regression test for the program reported in #12104 to keep it fixed. Test Plan: make test TEST=T12104 Reviewers: bgamari, austin Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #12104 Differential Revision: https://phabricator.haskell.org/D3495 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12104: Type families, `TypeError`, and `-fdefer-type-errors` cause "opt_univ fell into a hole" -------------------------------------+------------------------------------- Reporter: antalsz | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Keywords: TypeFamilies, Resolution: fixed | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #13487 | Differential Rev(s): Phab:D3495 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.2.1 Comment: Will merge fix for #13487 to 8.2. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12104#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC