Skip to content

SCC on partially applied primop causes a compiler panic.

This code:

{-# language MagicHash #-}

module Test where

import GHC.Exts

foo x = ({-# SCC foo #-} tagToEnum#) x :: Bool

Generates this core:

-- RHS size: {terms: 9, types: 13, coercions: 0, joins: 0/1}
Test.foo :: GHC.Prim.Int# -> GHC.Types.Bool
[GblId]
Test.foo
  = case tick<foo>
         let {
           sat_syT [Occ=Once1T[0]] :: forall {a}. GHC.Prim.Int# -> a
           [LclId]
           sat_syT
             = \ (@a_11) (eta_B0 [Occ=Once1] :: GHC.Prim.Int#) ->
                 GHC.Prim.tagToEnum# @a_11 eta_B0 } in
         sat_syT
    of sat_syU [Occ=Once1]
    { __DEFAULT ->
    sat_syU @GHC.Types.Bool
    }

Which causes codegen to panic because we don't have a concrete type on the tagToEnum# application.

The proper fix is probably to expand the tick scope up to whatever we eta expand to during CorePrep.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information