haskell / play-haskell

Haskell Playground
125 stars 8 forks source link

Panic on dumping core with Data deriving #39

Closed s-and-witch closed 11 months ago

s-and-witch commented 11 months ago

Reproduction

Link to the playground: https://play.haskell.org/saved/4fxoFT9Y

Code:

import Data.Data
main :: IO ()
main = pure ()

data X = A deriving Data

This code compiles and launches as expected, but attempt to dump core leads to GHC internal panic:

Error message:

GHC error in desugarer lookup in Main:
  attempting to use module ‘main:Main’ (input.hs) which is not loaded
ghc: panic! (the 'impossible' happened)
  (GHC version 9.2.5:
    initDs

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

It is not reproducible with local GHC, so I decided, that this is playground bug, not GHC.

tomsmeding commented 11 months ago

... what? :P

Notable is that this only seems to error with ghc >= 9.0; 8.10.7 and below work fine.

tomsmeding commented 11 months ago

Turns out it's this: https://github.com/haskell/play-haskell/blob/db259fd5183ea4536933fb9bdc3bcba74cb84b19/play-haskell-worker/bwrap-files/stage-3.sh#L32-L36

Indeed, doing ghc -dno-typeable-binds yourExample.hs locally gives the same error. I'll file a GHC bug; this is not a playground bug.

Thanks, this was a fun "wat" moment :)

s-and-witch commented 11 months ago

I'll file a GHC bug

This is not a GHC bug. Data wants Typeable which then relies on generated typeable binds, so, if they don't exist, how that should work?

tomsmeding commented 11 months ago

... this is not a GHC bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18175

Hence indeed this is a playground bug, introduced with #35. @alt-romes FYI, this is a thing. :)

I'll disable the flag. I'm locally working on a patch that adds a UI for user-customisation of some -d Core formatting flags; this will go in there instead.

Thanks for the report!