diff options
author | romes <rodrigo.m.mesquita@gmail.com> | 2022-03-12 01:08:00 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-18 05:10:58 -0400 |
commit | b056adc8062b4fe015450a21eb70e32dcf7023f5 (patch) | |
tree | a29805d0c2ea73000497eeea311e77ce961d0a3c /compiler/GHC/Tc/Gen/Splice.hs | |
parent | 4a2567f5641a4807584c90015dfc40a791f241b4 (diff) | |
download | haskell-b056adc8062b4fe015450a21eb70e32dcf7023f5.tar.gz |
TTG: Make HsQuote GhcTc isomorphic to NoExtField
An untyped bracket `HsQuote p` can never be constructed with
`p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all.
That's OK, because we also never use `HsQuote GhcTc`.
To enforce this at the type level we make `HsQuote GhcTc` isomorphic
to `NoExtField` and impossible to construct otherwise, by using TTG field
extensions to make all constructors, except for `XQuote` (which takes `NoExtField`),
unconstructable, with `DataConCantHappen`
This is explained more in detail in Note [The life cycle of a TH quotation]
Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782
Diffstat (limited to 'compiler/GHC/Tc/Gen/Splice.hs')
-rw-r--r-- | compiler/GHC/Tc/Gen/Splice.hs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs index bed8e14161..48464f5ca5 100644 --- a/compiler/GHC/Tc/Gen/Splice.hs +++ b/compiler/GHC/Tc/Gen/Splice.hs @@ -199,13 +199,7 @@ tcTypedBracket rn_expr expr res_ty -- Bundle them together so they can be used in GHC.HsToCore.Quote for desugaring -- brackets. ; let wrapper = QuoteWrapper ev_var m_var - -- Typecheck expr to make sure it is valid, - -- - -- romes TODO: The following is not actually that true: ppr_expr in - -- GHC.Hs.Expr uses this (and for untyped brackets the supposedly not - -- used type is also used). - -- If it isn't to be used, should the types enforce that? - -- + -- Typecheck expr to make sure it is valid. -- The typechecked expression won't be used, but we return it with its type. -- (See Note [The life cycle of a TH quotation] in GHC.Hs.Expr) -- We'll typecheck it again when we splice it in somewhere @@ -249,7 +243,7 @@ tcUntypedBracket rn_expr brack ps res_ty -- Unify the overall type of the bracket with the expected result -- type ; tcWrapResultO BracketOrigin rn_expr - (HsUntypedBracket (HsBracketTc brack expected_type brack_info ps') (XQuote brack)) + (HsUntypedBracket (HsBracketTc brack expected_type brack_info ps') (XQuote noExtField)) expected_type res_ty } |