Skip to content
  • sheaf's avatar
    81d65f7f
    Make withDict opaque to the specialiser · 81d65f7f
    sheaf authored
    As pointed out in #21575, it is not sufficient to set withDict to inline
    after the typeclass specialiser, because we might inline withDict in one
    module and then import it in another, and we run into the same problem.
    This means we could still end up with incorrect runtime results because
    the typeclass specialiser would assume that distinct typeclass evidence
    terms at the same type are equal, when this is not necessarily the case
    when using withDict.
    
    Instead, this patch introduces a new magicId, 'nospec', which is only
    inlined in CorePrep. We make use of it in the definition of withDict
    to ensure that the typeclass specialiser does not common up distinct
    typeclass evidence terms.
    
    Fixes #21575
    81d65f7f
    Make withDict opaque to the specialiser
    sheaf authored
    As pointed out in #21575, it is not sufficient to set withDict to inline
    after the typeclass specialiser, because we might inline withDict in one
    module and then import it in another, and we run into the same problem.
    This means we could still end up with incorrect runtime results because
    the typeclass specialiser would assume that distinct typeclass evidence
    terms at the same type are equal, when this is not necessarily the case
    when using withDict.
    
    Instead, this patch introduces a new magicId, 'nospec', which is only
    inlined in CorePrep. We make use of it in the definition of withDict
    to ensure that the typeclass specialiser does not common up distinct
    typeclass evidence terms.
    
    Fixes #21575
Loading