[Git][ghc/ghc][wip/less-defaulting] 2 commits: Change the defaulting rules in commitFlexi

Krzysztof Gogolewski (@monoidal) gitlab at gitlab.haskell.org
Mon Jun 19 22:42:17 UTC 2023



Krzysztof Gogolewski pushed to branch wip/less-defaulting at Glasgow Haskell Compiler / GHC


Commits:
e82b7497 by Krzysztof Gogolewski at 2023-06-20T00:00:55+02:00
Change the defaulting rules in commitFlexi

- Multiplicity isn't special, default to Any
- RuntimeRep and Levity are special only when concrete

- - - - -
1d8bf940 by Krzysztof Gogolewski at 2023-06-20T00:39:53+02:00
Workaround 23380

Without it, fails on

f :: Bool -> Bool
f x = case x of
        True -> True
        a -> a

- - - - -


1 changed file:

- compiler/GHC/Tc/Zonk/Type.hs


Changes:

=====================================
compiler/GHC/Tc/Zonk/Type.hs
=====================================
@@ -456,21 +456,24 @@ commitFlexi tv zonked_kind
              --    y = (\x -> True) undefined
              -- We need *some* known RuntimeRep for the x and undefined, but no one
              -- will choose it until we get here, in the zonker.
-           | isRuntimeRepTy zonked_kind
-           -> do { traceTc "Defaulting flexi tyvar to LiftedRep:" (pprTyVar tv)
-                 ; return liftedRepTy }
-           | isLevityTy zonked_kind
-           -> do { traceTc "Defaulting flexi tyvar to Lifted:" (pprTyVar tv)
-                 ; return liftedDataConTy }
            | isMultiplicityTy zonked_kind
            -> do { traceTc "Defaulting flexi tyvar to Many:" (pprTyVar tv)
                  ; return manyDataConTy }
-           | Just (ConcreteFRR origin) <- isConcreteTyVar_maybe tv
-           -> do { addErr $ TcRnZonkerMessage (ZonkerCannotDefaultConcrete origin)
-                 ; return (anyTypeOfKind zonked_kind) }
            | otherwise
-           -> do { traceTc "Defaulting flexi tyvar to Any:" (pprTyVar tv)
-                 ; return (anyTypeOfKind zonked_kind) }
+           -> case isConcreteTyVar_maybe tv of
+                Nothing
+                  -> do { traceTc "Defaulting flexi tyvar to Any:" (pprTyVar tv)
+                        ; return (anyTypeOfKind zonked_kind) }
+                Just (ConcreteFRR origin)
+                  | isRuntimeRepTy zonked_kind
+                  -> do { traceTc "Defaulting flexi tyvar to LiftedRep:" (pprTyVar tv)
+                        ; return liftedRepTy }
+                  | isLevityTy zonked_kind
+                  -> do { traceTc "Defaulting flexi tyvar to Lifted:" (pprTyVar tv)
+                        ; return liftedDataConTy }
+                  | otherwise
+                 -> do { addErr $ TcRnZonkerMessage (ZonkerCannotDefaultConcrete origin)
+                       ; return (anyTypeOfKind zonked_kind) }
 
          RuntimeUnkFlexi
            -> do { traceTc "Defaulting flexi tyvar to RuntimeUnk:" (pprTyVar tv)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f95a33363b385508d77de3983179e7cccc2318a3...1d8bf940d135737acf4d030a8b746221a2a5cbbb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f95a33363b385508d77de3983179e7cccc2318a3...1d8bf940d135737acf4d030a8b746221a2a5cbbb
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/20230619/17e25f5a/attachment-0001.html>


More information about the ghc-commits mailing list