[GHC] #12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _"

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I got the following error compiling simple source file Bad.hs. The bug is likely related to TH as the crash vanishes without the TH line. $ stack ghc -- -c Bad.hs Run from outside a project, using implicit global project config Using resolver: lts-7.5 from implicit global project's config file: /home/jchia/.stack/global-project/stack.yaml ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): compiler/typecheck/TcExpr.hs:798:15-35: Irrefutable pattern failed for pattern sel_id : _ Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by jchia): * Attachment "Bad.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jchia): I can reproduce the error under Stack LTS-7.5, so this is with aeson-0.11.2.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Here's a version which doesn't require installing `aeson`: {{{#!hs -- Bug2.hs module Bug2 where import Language.Haskell.TH data Options = Options { fieldLabelModifier :: String -> String , constructorTagModifier :: String -> String , allNullaryToStringTag :: Bool , omitNothingFields :: Bool , sumEncoding :: SumEncoding , unwrapUnaryRecords :: Bool } data SumEncoding = TaggedObject { tagFieldName :: String , contentsFieldName :: String } | ObjectWithSingleField | TwoElemArray deriveJSON :: Options -> Name -> Q [Dec] deriveJSON _ _ = return [] }}} {{{#!hs -- Bug.hs {-# LANGUAGE TemplateHaskell #-} module Bug where import Bug2 import Language.Haskell.TH data Bad = Bad { _bad :: String } deriving (Eq, Ord, Show) $(deriveJSON defaultOptions{} ''Bad) }}} {{{ $ /opt/ghc/head/bin/ghc Bug.hs [1 of 2] Compiling Bug2 ( Bug2.hs, Bug2.o ) [2 of 2] Compiling Bug ( Bug.hs, Bug.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.1.20161010 for x86_64-unknown-linux): compiler/typecheck/TcExpr.hs:820:15-35: Irrefutable pattern failed for pattern sel_id : _ Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- @@ -3,1 +3,1 @@ - + {{{ @@ -15,0 +15,1 @@ + }}} New description: I got the following error compiling simple source file Bad.hs. The bug is likely related to TH as the crash vanishes without the TH line. {{{ $ stack ghc -- -c Bad.hs Run from outside a project, using implicit global project config Using resolver: lts-7.5 from implicit global project's config file: /home/jchia/.stack/global-project/stack.yaml ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): compiler/typecheck/TcExpr.hs:798:15-35: Irrefutable pattern failed for pattern sel_id : _ Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Comment (by simonpj): Thank you Ryan! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Well that's odd. I get {{{ T12788.hs:11:14: error: Empty record update }}} which comes from `RnPat.rnHsRecUpdFields`. And is quite correct. If I change the program to {{{ $(deriveJSON defaultOptions{unwrapUnaryRecords = True} ''Bad) }}} then I get {{{ T12788.hs:11:14: error: Variable not in scope: defaultOptions :: Options }}} which is also correct; `defaultOptions` is not in scope. All this happens with the 8.0.2 release candidate and HEAD. I can't easily try 8.0 itself. Can you try with the 8.0 branch and HEAD? It really would be better if the "empty record update" didn't mask the other error, namely that `defaultOptions` isn't in scope. Reason is the latter is reported by the type checker so that we can give the type of the out-of-scope variable, whereas the former comes from the renamer. Regardless, I can't make it crash. Maybe it got fixed, somehow? Can you double-check the repro case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Ah! It turns out the error I experienced was with versions of GHC 8.0.2 and HEAD built on October 10. I experienced the same errors as you reported when using: * A GHC 8.0.2 built on October 18 * A GHC HEAD built on October 23 So this GHC panic must have been fixed recently. I'll try to find the offending commit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Ah, it turns out to be bce99086e9f54909f51ff5a74cb8c666083bb021 (a.k.a. #12584) yet again. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | 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: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): OK good, thank you. So we can close as fixed? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id :
_"
-------------------------------------+-------------------------------------
Reporter: jchia | 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: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => merge * milestone: => 8.0.2 Comment: I added a regression test to be safe. Since this fix was backported to 8.0.2, it should be safe to merge that commit as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12788: While using Data.Aeson.TH, "Irrefutable pattern failed for pattern sel_id : _" -------------------------------------+------------------------------------- Reporter: jchia | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as b72b7c8a2e23196a7d5e1d72dbb8f1b790545cda. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12788#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC