summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@richarde.dev>2019-09-26 14:31:30 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-08 13:26:20 -0400
commit9612e91c793830b3049d2bc9a9ee28d9d82b928d (patch)
treef34d5c1f295026aaf1e706b8e2d20426fad6ac23 /compiler/rename
parentbf02c26402cf926d41c006ab930ed9747e92a373 (diff)
downloadhaskell-9612e91c793830b3049d2bc9a9ee28d9d82b928d.tar.gz
Solve constraints from top-level groups sooner
Previously, all constraints from all top-level groups (as separated by top-level splices) were lumped together and solved at the end. This could leak metavariables to TH, though, and that's bad. This patch solves each group's constraints before running the next group's splice. Naturally, we now report fewer errors in some cases. One nice benefit is that this also fixes #11680, but in a much simpler way than the original fix for that ticket. Admittedly, the error messages degrade just a bit from the fix from #11680 (previously, we informed users about variables that will be brought into scope below a top-level splice, and now we just report an out-of-scope error), but the amount of complexity required throughout GHC to get that error was just not worth it. This patch thus reverts much of f93c9517a2c6e158e4a5c5bc7a3d3f88cb4ed119. Fixes #16980 Test cases: th/T16980{,a}
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnExpr.hs6
-rw-r--r--compiler/rename/RnSource.hs2
-rw-r--r--compiler/rename/RnTypes.hs4
3 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 3ec24a7a6d..42d38c23e9 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -108,11 +108,7 @@ rnUnboundVar v
then -- Treat this as a "hole"
-- Do not fail right now; instead, return HsUnboundVar
-- and let the type checker report the error
- do { let occ = rdrNameOcc v
- ; uv <- if startsWithUnderscore occ
- then return (TrueExprHole occ)
- else OutOfScope occ <$> getGlobalRdrEnv
- ; return (HsUnboundVar noExtField uv, emptyFVs) }
+ return (HsUnboundVar noExtField (rdrNameOcc v), emptyFVs)
else -- Fail immediately (qualified name)
do { n <- reportUnboundName v
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 1ab80e755a..ea8cfb5347 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -1141,7 +1141,7 @@ badRuleLhsErr name lhs bad_e
text "LHS must be of form (f e1 .. en) where f is not forall'd"
where
err = case bad_e of
- HsUnboundVar _ uv -> notInScopeErr (mkRdrUnqual (unboundVarOcc uv))
+ HsUnboundVar _ uv -> notInScopeErr (mkRdrUnqual uv)
_ -> text "Illegal expression:" <+> ppr bad_e
{- **************************************************************
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index 5f0a1c62c7..87f364011e 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -1180,7 +1180,7 @@ mkOpAppRn e1 op fix e2 -- Default case, no rearrangment
-- | Name of an operator in an operator application or section
data OpName = NormalOp Name -- ^ A normal identifier
| NegateOp -- ^ Prefix negation
- | UnboundOp UnboundVar -- ^ An unbound indentifier
+ | UnboundOp OccName -- ^ An unbound indentifier
| RecFldOp (AmbiguousFieldOcc GhcRn)
-- ^ A (possibly ambiguous) record field occurrence
@@ -1347,7 +1347,7 @@ checkSectionPrec direction section op arg
lookupFixityOp :: OpName -> RnM Fixity
lookupFixityOp (NormalOp n) = lookupFixityRn n
lookupFixityOp NegateOp = lookupFixityRn negateName
-lookupFixityOp (UnboundOp u) = lookupFixityRn (mkUnboundName (unboundVarOcc u))
+lookupFixityOp (UnboundOp u) = lookupFixityRn (mkUnboundName u)
lookupFixityOp (RecFldOp f) = lookupFieldFixityRn f