[Git][ghc/ghc][wip/int-index/term-capture] Term variable capture (#23740)

Vladislav Zavialov (@int-index) gitlab at gitlab.haskell.org
Sun Nov 26 00:09:24 UTC 2023



Vladislav Zavialov pushed to branch wip/int-index/term-capture at Glasgow Haskell Compiler / GHC


Commits:
1d6f4ba2 by Vladislav Zavialov at 2023-11-26T03:07:58+03: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/1d6f4ba2765a28a357b159bb8a1fba935e96442e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d6f4ba2765a28a357b159bb8a1fba935e96442e
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/20231125/7f4b69f6/attachment.html>


More information about the ghc-commits mailing list