summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorYiyun Liu <yiyun.liu@tweag.io>2022-05-27 18:04:16 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-08-04 02:55:07 -0400
commit35aef18de6d04473da95cb5a19d5cc111ee7ec45 (patch)
tree6b7a91a7c48d913d48ad9cf5cc9c89efc263e03c /testsuite
parent97655ad88c42003bc5eeb5c026754b005229800c (diff)
downloadhaskell-35aef18de6d04473da95cb5a19d5cc111ee7ec45.tar.gz
Remove TCvSubst and use Subst for both term and type-level subst
This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types).
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/corelint/LintEtaExpand.stderr16
-rw-r--r--testsuite/tests/corelint/T21115b.stderr8
2 files changed, 12 insertions, 12 deletions
diff --git a/testsuite/tests/corelint/LintEtaExpand.stderr b/testsuite/tests/corelint/LintEtaExpand.stderr
index 366fae4bb3..47274d0cc6 100644
--- a/testsuite/tests/corelint/LintEtaExpand.stderr
+++ b/testsuite/tests/corelint/LintEtaExpand.stderr
@@ -2,17 +2,17 @@
Cannot eta expand ‘coerce’
The following type does not have a fixed runtime representation:
• a :: TYPE k
- Substitution: [TCvSubst
- In scope: InScope {a q}
- Type env: []
- Co env: []]
+ Substitution: <InScope = {a q}
+ IdSubst = []
+ TvSubst = []
+ CvSubst = []>
in coerce BAD 1
<no location info>: warning:
Cannot eta expand ‘coerce’
The following type does not have a fixed runtime representation:
• a :: TYPE q
- Substitution: [TCvSubst
- In scope: InScope {a q}
- Type env: []
- Co env: []]
+ Substitution: <InScope = {a q}
+ IdSubst = []
+ TvSubst = []
+ CvSubst = []>
in coerce BAD 2
diff --git a/testsuite/tests/corelint/T21115b.stderr b/testsuite/tests/corelint/T21115b.stderr
index eaa70cc22f..1b245cf3c7 100644
--- a/testsuite/tests/corelint/T21115b.stderr
+++ b/testsuite/tests/corelint/T21115b.stderr
@@ -6,10 +6,10 @@ T21115b.hs:9:1: warning:
In the body of lambda with binder ds :: Double#
In the body of letrec with binders fail :: (# #) -> Int#
In the body of letrec with binders fail :: (# #) -> Int#
- Substitution: [TCvSubst
- In scope: InScope {}
- Type env: []
- Co env: []]
+ Substitution: <InScope = {}
+ IdSubst = []
+ TvSubst = []
+ CvSubst = []>
*** Offending Program ***
Rec {
$trModule = Module (TrNameS "main"#) (TrNameS "T21115b"#)