Note [nospecId magic]
The 'nospec' magic Id is used to ensure to make a value opaque to the typeclass specialiser. In CorePrep, we inline 'nospec', turning (nospec e) into e. Note that this happens *after* unfoldings are exposed in the interface file. This is crucial: otherwise, we could import an unfolding in which 'nospec' has been inlined (= erased), and we would lose the benefit. 'nospec' is used: * In the implementation of 'withDict': we insert 'nospec' so that the typeclass specialiser doesn't assume any two evidence terms of the same type are equal. See Note [withDict] in GHC.Tc.Instance.Class, and see test case T21575b for an example. * To defeat the specialiser when we have incoherent instances. See Note [Coherence and specialisation: overview] in GHC.Core.InstEnv.
References 2
- Coherence and specialisation: overview GHC.Core.InstEnv
- withDict GHC.Tc.Instance.Class
Referenced by 6
- GHC.Core.InstEnv call site
- GHC.CoreToStg.Prep call site
- GHC.HsToCore.Expr call site
- Desugaring non-canonical evidence GHC.HsToCore.Expr
- withDict GHC.Tc.Instance.Class
- GHC.Types.Id.Make call site