GHC issues
https://gitlab.haskell.org/ghc/ghc/-/issues
2020-01-16T20:05:04Z
https://gitlab.haskell.org/ghc/ghc/-/issues/16288
Core Lint error: Occurrence is GlobalId, but binding is LocalId
2020-01-16T20:05:04Z
Krzysztof Gogolewski
Core Lint error: Occurrence is GlobalId, but binding is LocalId
Compiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)
To reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Rep...
Compiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)
To reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Repro/B.hs`. The reproduction code is minimized version of code from cabal and prettyprint libraries.
A.hs
```haskell
module Repro.A where
import Repro.C
data License
class Pretty a where
pretty :: a -> Doc
instance Pretty License where
pretty _ = pretV
bar :: (Pretty a) => a -> Doc
bar w = foo (pretty (u w w w w))
u :: a -> a -> a -> a -> a
u = u
```
B.hs
```haskell
module Repro.B where
import Repro.A
import Repro.C
bar2 :: License -> Doc
bar2 = bar
```
C.hs
```haskell
module Repro.C where
data Doc = Empty | Beside Doc
hcat :: Doc -> Doc
hcat Empty = Empty
hcat xs = hcat xs
pretV = hcat Empty
foo :: Doc -> Doc
foo Empty = hcat Empty
foo val = Beside val
```
The error:
```
*** Core Lint errors : in result of Simplifier ***
Repro/C.hs:9:1: warning:
[in body of letrec with binders pretV_r3 :: Doc]
Occurrence is GlobalId, but binding is LocalId
pretV :: Doc
[GblId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]
*** Offending Program ***
lvl_s1kN :: Doc
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=True, Expandable=False, Guidance=IF_ARGS [] 30 20}]
lvl_s1kN
= case pretV of wild_Xd {
Empty -> pretV;
Beside ipv_s105 -> Beside wild_Xd
}
$sbar_s1kL [InlPrag=NOUSERINLINE[2]] :: License -> Doc
[LclId,
Arity=1,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)
Tmpl= \ _ [Occ=Dead] ->
case pretV of wild_Xd [Occ=Once*] {
Empty ->
let {
pretV_r3 :: Doc
[LclId]
pretV_r3 = wild_Xd } in
pretV;
Beside _ [Occ=Dead] -> Beside wild_Xd
}}]
$sbar_s1kL = \ _ [Occ=Dead] -> lvl_s1kN
$trModule_s1kE :: Addr#
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$trModule_s1kE = "main"#
$trModule_s1kF :: TrName
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s1kF = TrNameS $trModule_s1kE
$trModule_s1kG :: Addr#
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}]
$trModule_s1kG = "Repro.B"#
$trModule_s1kH :: TrName
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s1kH = TrNameS $trModule_s1kG
$trModule :: Module
[LclIdX,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$trModule = Module $trModule_s1kF $trModule_s1kH
bar2 :: License -> Doc
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 20}]
bar2
= \ _ [Occ=Dead] ->
case pretV of wild_Xd {
Empty -> pretV;
Beside ipv_s105 -> Beside wild_Xd
}
*** End of Offense ***
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | aspiwack |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Core Lint error: Occurrence is GlobalId, but binding is LocalId","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["aspiwack"],"type":"Bug","description":"Compiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)\r\n\r\nTo reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Repro/B.hs`. The reproduction code is minimized version of code from cabal and prettyprint libraries.\r\n\r\nA.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.A where\r\n\r\nimport Repro.C\r\n\r\ndata License\r\n\r\nclass Pretty a where\r\n pretty :: a -> Doc\r\n\r\ninstance Pretty License where\r\n pretty _ = pretV\r\n\r\nbar :: (Pretty a) => a -> Doc\r\nbar w = foo (pretty (u w w w w))\r\n\r\nu :: a -> a -> a -> a -> a\r\nu = u\r\n}}}\r\n\r\nB.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.B where\r\n\r\nimport Repro.A\r\nimport Repro.C\r\n\r\nbar2 :: License -> Doc\r\nbar2 = bar\r\n}}}\r\n\r\nC.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.C where\r\n\r\ndata Doc = Empty | Beside Doc\r\n\r\nhcat :: Doc -> Doc\r\nhcat Empty = Empty\r\nhcat xs = hcat xs\r\n\r\npretV = hcat Empty\r\n\r\nfoo :: Doc -> Doc\r\nfoo Empty = hcat Empty\r\nfoo val = Beside val\r\n}}}\r\n\r\nThe error:\r\n\r\n{{{\r\n*** Core Lint errors : in result of Simplifier ***\r\nRepro/C.hs:9:1: warning:\r\n [in body of letrec with binders pretV_r3 :: Doc]\r\n Occurrence is GlobalId, but binding is LocalId\r\n pretV :: Doc\r\n [GblId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]\r\n*** Offending Program ***\r\nlvl_s1kN :: Doc\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=True, Expandable=False, Guidance=IF_ARGS [] 30 20}]\r\nlvl_s1kN\r\n = case pretV of wild_Xd {\r\n Empty -> pretV;\r\n Beside ipv_s105 -> Beside wild_Xd\r\n }\r\n\r\n$sbar_s1kL [InlPrag=NOUSERINLINE[2]] :: License -> Doc\r\n[LclId,\r\n Arity=1,\r\n Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)\r\n Tmpl= \\ _ [Occ=Dead] ->\r\n case pretV of wild_Xd [Occ=Once*] {\r\n Empty ->\r\n let {\r\n pretV_r3 :: Doc\r\n [LclId]\r\n pretV_r3 = wild_Xd } in\r\n pretV;\r\n Beside _ [Occ=Dead] -> Beside wild_Xd\r\n }}]\r\n$sbar_s1kL = \\ _ [Occ=Dead] -> lvl_s1kN\r\n\r\n$trModule_s1kE :: Addr#\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]\r\n$trModule_s1kE = \"main\"#\r\n\r\n$trModule_s1kF :: TrName\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]\r\n$trModule_s1kF = TrNameS $trModule_s1kE\r\n\r\n$trModule_s1kG :: Addr#\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}]\r\n$trModule_s1kG = \"Repro.B\"#\r\n\r\n$trModule_s1kH :: TrName\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]\r\n$trModule_s1kH = TrNameS $trModule_s1kG\r\n\r\n$trModule :: Module\r\n[LclIdX,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]\r\n$trModule = Module $trModule_s1kF $trModule_s1kH\r\n\r\nbar2 :: License -> Doc\r\n[LclIdX,\r\n Arity=1,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 20}]\r\nbar2\r\n = \\ _ [Occ=Dead] ->\r\n case pretV of wild_Xd {\r\n Empty -> pretV;\r\n Beside ipv_s105 -> Beside wild_Xd\r\n }\r\n\r\n*** End of Offense ***\r\n\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->
8.8.2
https://gitlab.haskell.org/ghc/ghc/-/issues/17334
GHC can't find weight for edge that should have one
2020-02-25T01:09:40Z
Bodigrim
GHC can't find weight for edge that should have one
## Summary
GHC panics while compiling `fetchAndIntArray#` / `fetchOrIntArray#`.
```
[ 5 of 13] Compiling Data.Bit.MutableTS
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.1 for x86_64-apple-darwin):
Can't find weight for...
## Summary
GHC panics while compiling `fetchAndIntArray#` / `fetchOrIntArray#`.
```
[ 5 of 13] Compiling Data.Bit.MutableTS
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.1 for x86_64-apple-darwin):
Can't find weight for edge that should have one
triple (nQaY, nQwj, sKLs)
updates [(cPjA, nQwR, sL5U), (cPjx, nQwQ, sL5U),
...
(cOPS, nQwl, sKKV), (cOPy, nQwk, sKLs), (nQaY, nQwj, sKLs),
...
(cOEj, nQv2, sKED), (cOEm, nQv1, sKED)]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/nativeGen/CFG.hs:423:11 in ghc:CFG
```
## Steps to reproduce
```
git clone https://github.com/Bodigrim/bitvec.git
git checkout bc84af009921802106239d5e963e00abd1ec7003
stack build
```
This will fail with an error message, quoted above.
Sorry for such a broad description; at the moment I do not have time to whittle it down. I suspect that the problematic piece is in `Data.Bit.InternalTS`:
```
let W# andMask# = hiMask lenMod
W# orMask# = x .&. loMask lenMod
primitive $ \state ->
let !(# state', _ #) = fetchAndIntArray# mba loIx# (word2Int# andMask#) state in
let !(# state'', _ #) = fetchOrIntArray# mba loIx# (word2Int# orMask#) state' in
(# state'', () #)
```
## Expected behavior
I expect this package to compile successfully.
## Environment
* GHC version used: 8.8.1 for x86_64-apple-darwin
It seems to be a regression since GHC 8.6.5, as witnessed by these Travis builds:
* GHC 8.6.5: https://travis-ci.org/Bodigrim/bitvec/jobs/595834070
* GHC 8.8.1: https://travis-ci.org/Bodigrim/bitvec/jobs/595834069
8.8.2