[Git][ghc/ghc][wip/andreask/ghci-tag-nullary] 2 commits: Spaces at end
Andreas Klebinger (@AndreasK)
gitlab at gitlab.haskell.org
Tue Aug 16 12:54:01 UTC 2022
Andreas Klebinger pushed to branch wip/andreask/ghci-tag-nullary at Glasgow Haskell Compiler / GHC
Commits:
8af74b1c by Andreas Klebinger at 2022-08-16T13:19:48+02:00
Spaces at end
- - - - -
9b27cd3d by Andreas Klebinger at 2022-08-16T14:53:42+02:00
Fixes for GHCi
- - - - -
3 changed files:
- compiler/GHC/Stg/InferTags/Rewrite.hs
- testsuite/tests/simplStg/should_run/T22042.hs
- testsuite/tests/simplStg/should_run/T22042a.hs
Changes:
=====================================
compiler/GHC/Stg/InferTags/Rewrite.hs
=====================================
@@ -26,7 +26,7 @@ import GHC.Types.Name
import GHC.Types.Unique.Supply
import GHC.Types.Unique.FM
import GHC.Types.RepType
-import GHC.Unit.Types (Module)
+import GHC.Unit.Types (Module, isInteractiveModule)
import GHC.Core.DataCon
import GHC.Core (AltCon(..) )
@@ -212,16 +212,42 @@ withLcl fv act = do
setFVs old_fvs
return r
+{- Note [Tag inference for interactive contexts]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When running code in GHCi we perform tag inference/rewrites
+for each individual STG expression entered on the prompt.
+
+This means in GHCi for a sequence of:
+ > let x = True
+ > let y = x
+We first run tagInference for `x = True`. While that computes a tag signature for `x` that information
+is currently not persistet.
+Then we process `y = x`, and to do so we check for the tag sig of `x` (which we don't have).
+This isn't a problem as we can always just default to TagDunno and nothing bad will happen.
+
+But in a non-interactive context this would indicate an error as every binding
+should be processed in dependency order for the whole module at once.
+Therefore taggedness information should be available for every id mentioned in any RHS.
+
+So if a lookup fails we check if we are in an interactive context. If so we just default
+to TagDunno. If we aren't in an interactive context this is an error and we have an assert
+to check that.
+
+-}
isTagged :: Id -> RM Bool
isTagged v = do
this_mod <- getMod
+ -- See Note [Tag inference for interactive contexts]
+ let lookupDefault v = assertPpr (isInteractiveModule this_mod)
+ (text "unknown Id:" <> ppr this_mod <+> ppr v)
+ (TagSig TagDunno)
case nameIsLocalOrFrom this_mod (idName v) of
True
| isUnliftedType (idType v)
-> return True
| otherwise -> do -- Local binding
!s <- getMap
- let !sig = lookupWithDefaultUFM s (pprPanic "unknown Id:" (ppr v)) v
+ let !sig = lookupWithDefaultUFM s (lookupDefault v) v
return $ case sig of
TagSig info ->
case info of
=====================================
testsuite/tests/simplStg/should_run/T22042.hs
=====================================
@@ -3,4 +3,4 @@ module Main where
import T22042a
main = do
- putStrLn (foo $ SC A B C)
\ No newline at end of file
+ putStrLn (foo $ SC A B C)
=====================================
testsuite/tests/simplStg/should_run/T22042a.hs
=====================================
@@ -7,4 +7,4 @@ data C = C | AC deriving Show
data SC = SC !A !B !C
foo :: SC -> String
-foo (SC a b c) = show a ++ show b ++ show c
\ No newline at end of file
+foo (SC a b c) = show a ++ show b ++ show c
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08648849359218f1d6943b920b1f27fa690d4de9...9b27cd3d8620dbe32208b2fbc8d98b3aeefc45dc
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08648849359218f1d6943b920b1f27fa690d4de9...9b27cd3d8620dbe32208b2fbc8d98b3aeefc45dc
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220816/8d5646b3/attachment-0001.html>
More information about the ghc-commits
mailing list