Skip to content

Ambiguous record field name destructure on qualified imported modules causes compiler crash

I have two extremely simple files which will reproduce this crash.

Main.hs:

module Main where

import qualified B as B

x = 0

main :: IO ()
main = do let B.T { x = inside } = B.value
          putStrLn (show inside)

B.hs

module B where

data T = T { x :: Bool }

value :: T
value = T { x = True }

I did a qualified import of one module into the main module. I tried to destructure a record from this module, but I didn't qualify the record fields in the destructuring expression.

The output of the compiler is below:

Building ghcbug-repro-0.1.0.0...
Preprocessing executable 'ghcbug-repro' for ghcbug-repro-0.1.0.0...
[2 of 2] Compiling Main             ( Main.hs, dist/build/ghcbug-repro/ghcbug-repro-tmp/Main.o )

<no location info>: error:
    ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
	translateConPatVec: lookup

Please report this as a GHC bug:
http://www.haskell.org/ghc/reportabug
Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information