[GHC] #8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ----------------------------------+--------------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Compile-time crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ----------------------------------+--------------------------------------- Hello, This is my first bug report for GHC. I encountered a type error when compiling my program that said to report the error as a bug here. I tried searching for similar bugs, but could not find any bugs with the same problem. I'm sorry in advance if I have misunderstood anything or if there indeed are any duplicates of this problem! '''The error output''' {{{ src/app/Templates/Pages.hs:214:17: Constructor `Image' does not have field `filepath' In the pattern: Image {filepath = fp} In a pattern binding: Image {filepath = fp} = logo In an equation for `renderLogo': renderLogo (Design {mlogo = (Just logo)}) = H.a ! A.href "/" ! A.class_ "navbar-brand" $ H.img ! A.src (toValue fp) where Image {filepath = fp} = logo src/app/Templates/Pages.hs:214:34: Couldn't match expected type `Field' with actual type `Image' In the expression: logo In a pattern binding:ghc: panic! (the 'impossible' happened) (GHC version 7.6.3 for x86_64-unknown-linux): Bogus selector Id Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} '''When/why does this happen?''' I encountered this problem when I accidentally imported a field in a data named "Image" from module A, and imported the constructor of a different data structure from a different module also named "Image". I guess the type error itself is valid since it doesn't make sense to do what I did, but the way GHC handles this corner case internally is the source of the panic. Here are my imports: {{{ import Data.Image (Image(filepath)) import Data.Form (Field(..), FieldResult(..)) }}} Data.Image contains the data structure Image, whereas Data.Form contains the data structure Field which has a constructor named Image. Here is the the data structure in Data.Image: {{{ data Image = Image { id :: Integer , categoryId :: Integer , name :: String , filepath :: String , createdAt :: LocalTimestamp } deriving (Show) }}} And here is the data structure in Data.Form: {{{ data Field = Password Name Label | Text Name Label Value | Email Name Label Value | InlineArea Name Label Html | Hidden Name Value | Image Name Label | Select Name Label [SelectItem] SelectedId | CheckBox Name Label Selected }}} And here is the line I use the filepath field in my template file: {{{ where Image{filepath = fp} = logo }}} '''Can this GHC panic be avoided?''' Yes, by specifically importing from the same module. Like so: {{{ import Data.Image (Image(Image, filepath) import Data.Form (Field(InlineArea), FieldResult(..)) }}} ---- If there is anything more I can do to help, just let me know! Thank you Richard Zetterberg -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ---------------------------------------+---------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Compile-time crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ---------------------------------------+---------------------------------- Comment (by simonpj): I can't reproduce this. Here are the modules I used. I used these modules: {{{ module T8570a where data Image = Image { id :: Integer , categoryId :: Integer , name :: String , filepath :: String } deriving (Show) module T8570b where data Field = Password String | Image Int module T8570 where import T8570a (Image(filepath)) import T8570b (Field(..)) foo logo = fp where Image{filepath = fp} = logo }}} I compiled thus: {{{ bash$ ghc -c T8570a.hs bash$ ghc -c T8570b.hs bash$ ghc -c T8570.hs T8570.hs:6:27: Constructor `Image' does not have field `filepath' In the pattern: Image {filepath = fp} In a pattern binding: Image {filepath = fp} = logo In an equation for `foo': foo logo = fp where Image {filepath = fp} = logo }}} I tried with ghc-7.6.3 and HEAD. They all work fine. Can you offer a precise, reproducible test case? Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ---------------------------------------+---------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Compile-time crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ---------------------------------------+---------------------------------- Comment (by parcs): I can reproduce the error if `logo` is defined and imported from the module that defines `data Image`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ---------------------------------------+---------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Compile-time crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ---------------------------------------+---------------------------------- Comment (by simonpj): Can you give me the code? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ---------------------------------------+---------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Compile-time crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ---------------------------------------+---------------------------------- Comment (by parcs): This code reproduces the error: {{{ #!haskell module A where import B (Image(filepath), logo) import C (Field(Image)) foo = let Image {filepath = ()} = logo in () }}} {{{ module B where data Image = Image { filepath :: () } logo = Image () }}} {{{ module C where data Field = Image }}} {{{ $ ghc-stage2 A [1 of 3] Compiling C ( C.hs, C.o ) [2 of 3] Compiling B ( B.hs, B.o ) [3 of 3] Compiling A ( A.hs, A.o ) A.hs:6:18: Constructor ‛Image’ does not have field ‛filepath’ In the pattern: Image {filepath = ()} In a pattern binding: Image {filepath = ()} = logo In the expression: let Image {filepath = ()} = logo in () A.hs:6:35: Couldn't match expected type ‛Field’ with actual type ‛Image’ In the expression: logo In a pattern binding:ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131127 for x86_64-unknown-linux): Bogus selector Id Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} One-shot mode behaves similarly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus
selector Id
---------------------------------------+----------------------------------
Reporter: rzetterberg | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Compile-time crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
---------------------------------------+----------------------------------
Comment (by Simon Peyton Jones

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus
selector Id
---------------------------------------+----------------------------------
Reporter: rzetterberg | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Compile-time crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
---------------------------------------+----------------------------------
Comment (by Simon Peyton Jones

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus
selector Id
---------------------------------------+----------------------------------
Reporter: rzetterberg | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Compile-time crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
---------------------------------------+----------------------------------
Comment (by Simon Peyton Jones

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ---------------------------------------+---------------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Compile-time crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ---------------------------------------+---------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed Comment: Thank you! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8570: In a pattern binding:ghc: panic! (the 'impossible' happened): Bogus selector Id ------------------------------------------------+-------------------------- Reporter: rzetterberg | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time crash | (amd64) Test Case: typecheck/should_fail/T8570 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by simonpj): * testcase: => typecheck/should_fail/T8570 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8570#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC