summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Lint.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-02-26 14:51:59 +0100
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-03-04 20:38:38 +0100
commit32e394653ac467c79679a7545e6434f7677e605d (patch)
treee95a0f9913f33e9470efb8c205178c2bc6f6fdde /compiler/GHC/Core/Lint.hs
parentdf74e95ae76b30a7c1a9b155a3e8d58eabd054eb (diff)
downloadhaskell-wip/T19165.tar.gz
Run linear Lint on the desugarer output (part of #19165)wip/T19165
This addresses points (1a) and (1b) of #19165. - Move mkFailExpr to HsToCore/Utils, as it can be shared - Desugar incomplete patterns and holes to an empty case, as in Note [Incompleteness and linearity] - Enable linear linting of desugarer output - Mark MultConstructor as broken. It fails Lint, but I'd like to fix this separately. Metric Decrease: T6048
Diffstat (limited to 'compiler/GHC/Core/Lint.hs')
-rw-r--r--compiler/GHC/Core/Lint.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/GHC/Core/Lint.hs b/compiler/GHC/Core/Lint.hs
index 382851a1e5..40de306802 100644
--- a/compiler/GHC/Core/Lint.hs
+++ b/compiler/GHC/Core/Lint.hs
@@ -488,7 +488,8 @@ lintCoreBindings dflags pass local_in_scope binds
flags = (defaultLintFlags dflags)
{ lf_check_global_ids = check_globals
, lf_check_inline_loop_breakers = check_lbs
- , lf_check_static_ptrs = check_static_ptrs }
+ , lf_check_static_ptrs = check_static_ptrs
+ , lf_check_linearity = check_linearity }
-- See Note [Checking for global Ids]
check_globals = case pass of
@@ -510,6 +511,12 @@ lintCoreBindings dflags pass local_in_scope binds
CorePrep -> AllowAtTopLevel
_ -> AllowAnywhere
+ -- See Note [Linting linearity]
+ check_linearity = gopt Opt_DoLinearCoreLinting dflags || (
+ case pass of
+ CoreDesugar -> True
+ _ -> False)
+
(_, dups) = removeDups compare binders
-- dups_ext checks for names with different uniques
@@ -2641,11 +2648,12 @@ to work with Linear Lint:
in f True
uses 'x' linearly, but this is not seen by the linter.
Plan: make let-bound variables remember the usage environment.
- See test LinearLetRec and https://github.com/tweag/ghc/issues/405.
+ See ticket #18694.
We plan to fix both of the issues in the very near future.
-For now, linear Lint is disabled by default and
-has to be enabled manually with -dlinear-core-lint.
+For now, -dcore-lint enables only linting output of the desugarer,
+and full Linear Lint has to be enabled separately with -dlinear-core-lint.
+Ticket #19165 concerns enabling Linear Lint with -dcore-lint.
-}
instance Applicative LintM where