IaFP / ghc

A slightly more Glorious Haskell Compiler
Other
2 stars 0 forks source link

Something is amuck with template-haskell #40

Open ahubers opened 2 years ago

ahubers commented 2 years ago

What

When building unordered-containers w/ PTC, I am getting a panic from GHC for this instance in Data/HashMap/Internal/Array.hs:

instance TH.Lift a => TH.Lift (Array a) where
#if MIN_VERSION_template_haskell(2,16,0)
  liftTyped ar = [|| fromList' arlen arlist ||]
#else
  lift ar = [| fromList' arlen arlist |]
#endif
    where
      arlen :: Int
      arlen = I# (sizeofSmallArray# (unArray ar))
      arlist = toList ar

The panic is:

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.3.20220511:
    bind_args
  I#
  [ww, ww, ww]
  [sizeofSmallArray# @a ds]
  scrut: I# (sizeofSmallArray# @a ds)
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:186:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Core/Opt/Simplify.hs:3307:7 in ghc:GHC.Core.Opt.Simplify

I am kicking this issue down the river by commenting out any Template-Haskell support. Logging here for now.

Reproduction Steps

Follow instructions here to build unordered-containers package. Uncomment the instance TH.Lif a => ... line above in Data/Hashmap/Internal/Array.hs.

fxdpntthm commented 2 years ago

Template-haskell does not interact well with our elaboration machinery. The crux of the problem is that desugaring of quoted expressions with elaborated type signature is irregular. I don't think this is low priority. Rather a limitation of the current work/future work?