Skip to content

Core Lint error with SpecConstr + interpreter

This is a Core Lint error found during investigation of #22956.

To reproduce: compile master enabling optimisations for the interpreter:

diff --git a/compiler/GHC/Driver/Backend.hs b/compiler/GHC/Driver/Backend.hs
index e59f0a51f7..4663924599 100644
--- a/compiler/GHC/Driver/Backend.hs
+++ b/compiler/GHC/Driver/Backend.hs
@@ -710,7 +710,7 @@ backendForcesOptimization0 (Named NCG)         = False
 backendForcesOptimization0 (Named LLVM)        = False
 backendForcesOptimization0 (Named ViaC)        = False
 backendForcesOptimization0 (Named JavaScript)  = False
-backendForcesOptimization0 (Named Interpreter) = True
+backendForcesOptimization0 (Named Interpreter) = False
 backendForcesOptimization0 (Named NoBackend)   = False
 
 -- | I don't understand exactly how this works.  But if

and run ./stage1/bin/ghc --interactive -dlint -fspec-constr Internal with:

module Internal where

data N = Z | S N

union :: N -> ()
union Z = ()
union t = splitS t

splitS :: N -> ()
splitS Z = ()
splitS (S l) = splitS l
*** Core Lint errors : in result of SpecConstr ***
Internal.hs:10:1: warning:
    Out of scope: l_aBE :: N
                  [LclId]
    In the RHS of $ssplitS_sJ0 :: N -> ()
    In the body of lambda with binder sc_sIZ :: N
    Substitution: <InScope = {}
                   IdSubst   = []
                   TvSubst   = []
                   CvSubst   = []>

At the moment, ghci does not support optimisations, but the goal of #23056 (closed) is to add that support.

Edited by Krzysztof Gogolewski
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information