Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Kaznacheev
GHC
Commits
5fe872d3
Commit
5fe872d3
authored
10 years ago
by
Gergő Érdi
Browse files
Options
Downloads
Patches
Plain Diff
Apply compulsory unfoldings during desugaring, except for `seq` which is special.
See Note [Unfolding while desugaring] for the rationale.
parent
7f929862
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/deSugar/DsExpr.lhs
+21
-1
21 additions, 1 deletion
compiler/deSugar/DsExpr.lhs
with
21 additions
and
1 deletion
compiler/deSugar/DsExpr.lhs
+
21
−
1
View file @
5fe872d3
...
...
@@ -46,12 +46,14 @@ import MkCore
import DynFlags
import CostCentre
import Id
import Unique
import Module
import VarSet
import VarEnv
import ConLike
import DataCon
import TysWiredIn
import PrelNames ( seqIdKey )
import BasicTypes
import Maybes
import SrcLoc
...
...
@@ -191,7 +193,12 @@ dsLExpr (L loc e) = putSrcSpanDs loc $ dsExpr e
dsExpr :: HsExpr Id -> DsM CoreExpr
dsExpr (HsPar e) = dsLExpr e
dsExpr (ExprWithTySigOut e _) = dsLExpr e
dsExpr (HsVar var) = return (varToCoreExpr var) -- See Note [Desugaring vars]
dsExpr (HsVar var) -- See Note [Unfolding while desugaring]
| unfold_var = return $ unfoldingTemplate unfolding
| otherwise = return (varToCoreExpr var) -- See Note [Desugaring vars]
where
unfold_var = isCompulsoryUnfolding unfolding && not (var `hasKey` seqIdKey)
unfolding = idUnfolding var
dsExpr (HsIPVar _) = panic "dsExpr: HsIPVar"
dsExpr (HsLit lit) = dsLit lit
dsExpr (HsOverLit lit) = dsOverLit lit
...
...
@@ -220,6 +227,19 @@ dsExpr (HsApp fun arg)
dsExpr (HsUnboundVar _) = panic "dsExpr: HsUnboundVar"
\end{code}
Note [Unfolding while desugaring]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Variables with compulsory unfolding must be substituted at desugaring
time. This is needed to preserve the let/app invariant in cases where
the unfolding changes whether wrapping in a case is needed.
Suppose we have a call like this:
I# x
where 'x' has an unfolding like this:
f void#
In this case, 'mkCoreAppDs' needs to see 'f void#', not 'x', to be
able to do the right thing.
Note [Desugaring vars]
~~~~~~~~~~~~~~~~~~~~~~
In one situation we can get a *coercion* variable in a HsVar, namely
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment