[Git][ghc/ghc][master] Term variable capture (#23740)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sun Nov 26 16:46:24 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00
Term variable capture (#23740)

This patch changes type variable lookup rules (lookupTypeOccRn) and
implicit quantification rules (filterInScope) so that variables bound
in the term namespace can be captured at the type level

  {-# LANGUAGE RequiredTypeArguments #-}
  f1 x = g1 @x                -- `x` used in a type application
  f2 x = g2 (undefined :: x)  -- `x` used in a type annotation
  f3 x = g3 (type x)          -- `x` used in an embedded type
  f4 x = ...
    where g4 :: x -> x        -- `x` used in a type signature
          g4 = ...

This change alone does not allow us to accept examples shown above,
but at least it gets them past the renamer.

- - - - -


30 changed files:

- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types/PromotionErr.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Utils/Env.hs
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/rename/should_compile/T22513a.stderr
- testsuite/tests/rename/should_compile/T22513b.stderr
- testsuite/tests/rename/should_compile/T22513c.stderr
- testsuite/tests/rename/should_compile/T22513d.stderr
- testsuite/tests/rename/should_compile/T22513e.stderr
- testsuite/tests/rename/should_compile/T22513f.stderr
- testsuite/tests/rename/should_compile/T22513g.hs
- testsuite/tests/rename/should_compile/T22513g.stderr
- testsuite/tests/rename/should_compile/T22513h.stderr
- testsuite/tests/rename/should_compile/T22513i.stderr
- + testsuite/tests/rename/should_compile/T22513j.hs
- + testsuite/tests/rename/should_compile/T22513j.stderr
- testsuite/tests/rename/should_compile/all.T
- − testsuite/tests/rename/should_fail/T12686.hs
- − testsuite/tests/rename/should_fail/T12686.stderr
- + testsuite/tests/rename/should_fail/T12686a.hs
- + testsuite/tests/rename/should_fail/T12686a.stderr
- + testsuite/tests/rename/should_fail/T12686b.hs
- + testsuite/tests/rename/should_fail/T12686b.stderr
- + testsuite/tests/rename/should_fail/T12686c.hs
- + testsuite/tests/rename/should_fail/T12686c.stderr


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1bf25c7d4829ec5823974af2e8ea3821d724f25

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1bf25c7d4829ec5823974af2e8ea3821d724f25
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231126/d31e3191/attachment.html>


More information about the ghc-commits mailing list