
#14680: GHC 8.4.1-alpha panics when optimizing function using getTag and tagToEnum# -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.4.1 Component: Compiler | Version: 8.4.1-alpha1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Ryan and I talked by Skype. It seems that `dataToTag#` is truly polymorphic (works for values of any type), and GHC happily accepts {{{ get :: forall a. a -> Int# get x = getTag x }}} `dataToTag#` will never crash; it'll just fetch a tag from its argument's info table. Given that, the Right Thing is just to make sure that the optimisatio rule in `PrelRules` has enough side conditions. Currently it says {{{ caseRules _ (App (App (Var f) (Type ty)) v) -- dataToTag x | Just DataToTagOp <- isPrimOpId_maybe f = Just (v, tx_con_dtt ty , \v -> App (App (Var f) (Type ty)) (Var v)) }}} But it should also check that `ty` is a proper data type; if not, return `Nothing` (i.e. don't optimise). Easy. Ryan is on the job. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14680#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler