summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Ext/Ast.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/Iface/Ext/Ast.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/Iface/Ext/Ast.hs')
-rw-r--r--compiler/GHC/Iface/Ext/Ast.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs
index 3917998c3e..4bd9ed381d 100644
--- a/compiler/GHC/Iface/Ext/Ast.hs
+++ b/compiler/GHC/Iface/Ext/Ast.hs
@@ -165,7 +165,7 @@ For subtrees in the AST that may contain symbols, the procedure is fairly
straightforward. If you are extending the GHC AST, you will need to provide a
`ToHie` instance for any new types you may have introduced in the AST.
-Here are is an extract from the `ToHie` instance for (LHsExpr (GhcPass p)):
+Here is an extract from the `ToHie` instance for (LHsExpr (GhcPass p)):
toHie e@(L mspan oexpr) = concatM $ getTypeNode e : case oexpr of
HsVar _ (L _ var) ->
@@ -725,6 +725,7 @@ instance HiePass p => HasType (Located (HsExpr (GhcPass p))) where
HieTc ->
-- Some expression forms have their type immediately available
let tyOpt = case e' of
+ HsUnboundVar (HER _ ty _) _ -> Just ty
HsLit _ l -> Just (hsLitType l)
HsOverLit _ o -> Just (overLitType o)
@@ -764,7 +765,6 @@ instance HiePass p => HasType (Located (HsExpr (GhcPass p))) where
skipDesugaring :: HsExpr GhcTc -> Bool
skipDesugaring e = case e of
HsVar{} -> False
- HsUnboundVar{} -> False
HsConLikeOut{} -> False
HsRecFld{} -> False
HsOverLabel{} -> False
@@ -791,7 +791,6 @@ class ( IsPass p
, Data (HsTupArg (GhcPass p))
, Data (IPBind (GhcPass p))
, ToHie (Context (Located (IdGhcP p)))
- , ToHie (Context (Located (XUnboundVar (GhcPass p))))
, ToHie (RFContext (Located (AmbiguousFieldOcc (GhcPass p))))
, ToHie (RFContext (Located (FieldOcc (GhcPass p))))
, ToHie (TScoped (LHsWcType (GhcPass (NoGhcTcPass p))))
@@ -1053,8 +1052,7 @@ instance HiePass p => ToHie (Located (HsExpr (GhcPass p))) where
[ toHie $ C Use (L mspan var)
-- Patch up var location since typechecker removes it
]
- HsUnboundVar var _ ->
- [ toHie $ C Use (L mspan var) ]
+ HsUnboundVar _ _ -> [] -- there is an unbound name here, but that causes trouble
HsConLikeOut _ con ->
[ toHie $ C Use $ L mspan $ conLikeName con
]