Skip to content
  • Matthew Pickering's avatar
    Use actual universal tvs in check for naughty record selectors · 0e2839a2
    Matthew Pickering authored and Ben Gamari's avatar Ben Gamari committed
    The naughty record selector check means to limit selectors which would
    lead to existential tyvars escaping their scope. With record pattern
    synonyms, there are situations where universal tyvars don't appear in
    the result type, for example:
    
    ```
    pattern ReadP :: Read a => a -> String
    pattern ReadP{readp} <- (read -> readp)
    ```
    
    This is a similar issue to #11224 where we assumed that we can decide
    which variables are universal and which are existential by the syntactic
    check of seeing which appear in the result type. The fix is to use
    `univ_tvs` from `conLikeFullSig` rather than the previous approximation.
    But we must also remember to apply `EqSpec`s so we use the free
    variables from `inst_tys` which is precisely `univ_tvs` with `EqSpecs`
    applied.
    
    Reviewers: austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3649
    
    (cherry picked from commit 90771209)
    0e2839a2