summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@richarde.dev>2020-12-24 15:04:06 -0500
committerRichard Eisenberg <rae@richarde.dev>2020-12-24 15:09:44 -0500
commite9cc41df3f53db0e1fe39d970278cb630872a762 (patch)
tree086c73dfbde90f4b07f3c4c15972761dc2e2788c /compiler/GHC/Hs
parentb4508bd6f8b6492d2e74053d7338980109174861 (diff)
downloadhaskell-wip/T17812.tar.gz
Use mutable update to defer out-of-scope errorswip/T17812
Previously, we let-bound an identifier to use to carry the erroring evidence for an out-of-scope variable. But this failed for levity-polymorphic out-of-scope variables, leading to a panic (#17812). The new plan is to use a mutable update to just write the erroring expression directly where it needs to go. Close #17812. Test case: typecheck/should_compile/T17812
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Expr.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index ef8934b831..78b07e54a3 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -38,7 +38,6 @@ import GHC.Hs.Binds
-- others:
import GHC.Tc.Types.Evidence
import GHC.Core
-import GHC.Types.Id( Id )
import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Types.Basic
@@ -252,8 +251,10 @@ data HsExpr p
-- Turned from HsVar to HsUnboundVar by the
-- renamer, when it finds an out-of-scope
-- variable or hole.
- -- The (XUnboundVar p) field becomes Id
- -- after typechecking
+ -- The (XUnboundVar p) field becomes an HoleExprRef
+ -- after typechecking; this is where the
+ -- erroring expression will be written after
+ -- solving. See Note [Holes] in GHC.Tc.Types.Constraint.
| HsConLikeOut (XConLikeOut p)
ConLike -- ^ After typechecker only; must be different
@@ -608,7 +609,11 @@ type instance XApp (GhcPass _) = NoExtField
type instance XUnboundVar GhcPs = NoExtField
type instance XUnboundVar GhcRn = NoExtField
-type instance XUnboundVar GhcTc = Id
+type instance XUnboundVar GhcTc = HoleExprRef
+ -- We really don't need the whole HoleExprRef; just the IORef EvTerm
+ -- would be enough. But then deriving a Data instance becomes impossible.
+ -- Much, much easier just to define HoleExprRef with a Data instance and
+ -- store the whole structure.
type instance XAppTypeE GhcPs = NoExtField
type instance XAppTypeE GhcRn = NoExtField