GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:28:59Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/11709Merge some TypeInType fixes2019-07-07T18:28:59ZRichard Eisenbergrae@richarde.devMerge some TypeInType fixesThere are a few more commits to merge, that didn't fit with a single ticket:
- de4df6b41a227f527e9eb77733cd6c87b069d3d0
- 3f5d1a13f112f34d992f6b74656d64d95a3f506d
- 6c768fcf0d6749bf5029baf6b7f99271b48b1037
- 18fbfa39104b92a05061ec5f6f5b...There are a few more commits to merge, that didn't fit with a single ticket:
- de4df6b41a227f527e9eb77733cd6c87b069d3d0
- 3f5d1a13f112f34d992f6b74656d64d95a3f506d
- 6c768fcf0d6749bf5029baf6b7f99271b48b1037
- 18fbfa39104b92a05061ec5f6f5bf3b84b462605
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Merge some TypeInType fixes","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"There are a few more commits to merge, that didn't fit with a single ticket:\r\n\r\n* de4df6b41a227f527e9eb77733cd6c87b069d3d0\r\n* 3f5d1a13f112f34d992f6b74656d64d95a3f506d\r\n* 6c768fcf0d6749bf5029baf6b7f99271b48b1037\r\n* 18fbfa39104b92a05061ec5f6f5bf3b84b462605\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11702Constant folding on 'mod/Word' - incorrect result2019-07-07T18:29:02ZondrapConstant folding on 'mod/Word' - incorrect resultCompiling this with GHC 7.10.3 on both MacOS and Linux with '-O' producess results '5 0'.
```hs
module Main where
testfn :: Word -> IO ()
testfn wseq = do
print $ wseq `mod` 1
main = do
testfn 5
print $ (5 :: Word) `mod` 1
```
...Compiling this with GHC 7.10.3 on both MacOS and Linux with '-O' producess results '5 0'.
```hs
module Main where
testfn :: Word -> IO ()
testfn wseq = do
print $ wseq `mod` 1
main = do
testfn 5
print $ (5 :: Word) `mod` 1
```
Changing type to Int produces correct result. It has probably something to do with compiler/prelude/PrelRules.hs - the rules for Int and Word differ. It seems to me that it should be optimized the same way, but the culprit seems to be the 'rightIdentityDynFlags onew' - that seems to be a clear bug (if it does what I think it does).
```hs
primOpRules nm IntRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (intOp2 rem)
, leftZero zeroi
, do l <- getLiteral 1
dflags <- getDynFlags
guard (l == onei dflags)
retLit zeroi
, equalArgs >> retLit zeroi
, equalArgs >> retLit zeroi ]
primOpRules nm WordRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 rem)
, rightIdentityDynFlags onew ]
```
I found it in different code where lots of inlining reduced some branch of code into this and produced wrong result.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Prelude |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Constant folding on 'mod/Word' - incorrect result","status":"New","operating_system":"","component":"Prelude","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Compiling this with GHC 7.10.3 on both MacOS and Linux with '-O' producess results '5 0'. \r\n\r\n{{{#!hs\r\nmodule Main where\r\n\r\ntestfn :: Word -> IO ()\r\ntestfn wseq = do\r\n print $ wseq `mod` 1\r\n\r\nmain = do\r\n testfn 5\r\n print $ (5 :: Word) `mod` 1\r\n}}}\r\n\r\nChanging type to Int produces correct result. It has probably something to do with compiler/prelude/PrelRules.hs - the rules for Int and Word differ. It seems to me that it should be optimized the same way, but the culprit seems to be the 'rightIdentityDynFlags onew' - that seems to be a clear bug (if it does what I think it does).\r\n\r\n{{{#!hs\r\nprimOpRules nm IntRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (intOp2 rem)\r\n , leftZero zeroi\r\n , do l <- getLiteral 1\r\n dflags <- getDynFlags\r\n guard (l == onei dflags)\r\n retLit zeroi\r\n , equalArgs >> retLit zeroi\r\n , equalArgs >> retLit zeroi ]\r\nprimOpRules nm WordRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 rem)\r\n , rightIdentityDynFlags onew ]\r\n}}}\r\n\r\nI found it in different code where lots of inlining reduced some branch of code into this and produced wrong result.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/11662Regression using NamedFieldPuns with qualified field names2019-07-07T18:29:13ZhesselinkRegression using NamedFieldPuns with qualified field namesI found a regression where code using the NamedFieldPuns extension and qualified field names doesn't compile with GHC 8 rc2, where it did with GHC 7.10.
Minimal reproduction:
```hs
module Rec where
data Rec = Rec { f :: Integer }
---...I found a regression where code using the NamedFieldPuns extension and qualified field names doesn't compile with GHC 8 rc2, where it did with GHC 7.10.
Minimal reproduction:
```hs
module Rec where
data Rec = Rec { f :: Integer }
--------------------
{-# LANGUAGE NamedFieldPuns #-}
module Main where
import Rec (Rec (Rec))
import qualified Rec
g :: Rec -> Integer
g (Rec { Rec.f }) = f
```
On GHC 8 this fails with:
```
Main.hs:6:10: error: Qualified name in binding position: Rec.f
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Regression using NamedFieldPuns with qualified field names","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I found a regression where code using the NamedFieldPuns extension and qualified field names doesn't compile with GHC 8 rc2, where it did with GHC 7.10.\r\n\r\nMinimal reproduction:\r\n\r\n{{{#!hs\r\nmodule Rec where\r\n\r\ndata Rec = Rec { f :: Integer }\r\n\r\n--------------------\r\n\r\n{-# LANGUAGE NamedFieldPuns #-}\r\nmodule Main where\r\n\r\nimport Rec (Rec (Rec))\r\nimport qualified Rec\r\n\r\ng :: Rec -> Integer\r\ng (Rec { Rec.f }) = f\r\n}}}\r\n\r\nOn GHC 8 this fails with:\r\n\r\n{{{\r\nMain.hs:6:10: error: Qualified name in binding position: Rec.f\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Adam GundryAdam Gundryhttps://gitlab.haskell.org/ghc/ghc/-/issues/11651Allow plugins to define built-in rules2019-07-07T18:29:18ZSimon Peyton JonesAllow plugins to define built-in rulesConal Elliott has an application in which he wants a plugin to add some new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being compiled. He needs a built-in rule (which runs some custom code) rather than a vanilla `Cor...Conal Elliott has an application in which he wants a plugin to add some new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being compiled. He needs a built-in rule (which runs some custom code) rather than a vanilla `CoreRule` (which pattern-matches the argument).
But then he got a GHC panic
```
get a GHC panic: “No match in record selector ru_args”.
```
Turns out it comes from these lines in `OccAnal`
```
imp_rule_edges = foldr (plusVarEnv_C unionVarSet) emptyVarEnv
[ mapVarEnv (const maps_to) (exprFreeIds arg `delVarSetList` ru_bndrs imp_rule)
| imp_rule <- imp_rules
, let maps_to = exprFreeIds (ru_rhs imp_rule)
`delVarSetList` ru_bndrs imp_rule
, arg <- ru_args imp_rule ]
```
This code is just working out what locally-defined variables should be kept alive by the `mg_rules` for imported Ids. But `BuiltinRules` don't have any `ru_args`.
Easy fix: just don't traverse builtin rules in this scan. In Conal's case, the rules that his plugin adds certainly don't mention locally-defined Ids.
I'll do this shortly.8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11649LLVM code generator produces mal-formed LLVM blocks2020-01-07T04:30:58ZBen GamariLLVM code generator produces mal-formed LLVM blocksIt appears that the recent addition (673efccb3b348e9daf23d9e65460691bbea8586e) of some instances for types in `GHC.Generics` has uncovered a bug in the LLVM code generator (at least on ARM). `libraries/base/GHC/Generics.hs` fails to comp...It appears that the recent addition (673efccb3b348e9daf23d9e65460691bbea8586e) of some instances for types in `GHC.Generics` has uncovered a bug in the LLVM code generator (at least on ARM). `libraries/base/GHC/Generics.hs` fails to compile with,
```
Entry block to function must not have predecessors!
label %cjGw
/home/ben/ghc/roots/llvm-3.7/bin/opt: libraries/base/GHC/Generics.ll: error: input module is broken!
```
The problematic block in question appears to be,
```
define internal ghccc void @rhSw_info$def(i32* noalias nocapture %Base_Arg, i32* noalias nocapture %Sp_Arg, i32* noal
ias nocapture %Hp_Arg, i32 %R1_Arg, i32 %R2_Arg, i32 %R3_Arg, i32 %R4_Arg, i32 %SpLim_Arg) align 4 nounwind prefix <{
i32, i32, i32}><{i32 65541, i32 0, i32 15}>
{
clpH:
br label %clpH
}
```
Which arose from this Cmm,
```
==================== Post control-flow optimisations ====================
2016-02-26 10:39:28.656744 UTC
[section ""data" . lvl_rhSw_closure" {
lvl_rhSw_closure:
const lvl_rhSw_info;
},
lvl_rhSw_entry() // []
{ info_tbl: [(clpH,
label: lvl_rhSw_info
rep:HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} })]
stack_info: arg_space: 0 updfr_space: Nothing
}
{offset
clpH:
goto clpH; // CmmBranch
}
}]
```
Which arose from this input Cmm,
```
==================== Cmm produced by new codegen ====================
2016-02-26 10:39:28.611641 UTC
[section ""data" . lvl_rhSw_closure" {
lvl_rhSw_closure:
const lvl_rhSw_info;
},
lvl_rhSw_entry() // [R2]
{ info_tbl: [(clpD,
label: lvl_rhSw_info
rep:HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} })]
stack_info: arg_space: 4 updfr_space: Just 4
}
{offset
clpD:
_shWa::P32 = R2; // CmmAssign
goto clpz; // CmmBranch
clpz:
if ((old + 0) - <highSp> < SpLim) goto clpE; else goto clpF; // CmmCondBranch
clpE:
R2 = _shWa::P32; // CmmAssign
R1 = lvl_rhSw_closure; // CmmAssign
call (stg_gc_fun)(R2, R1) args: 4, res: 0, upd: 4; // CmmCall
clpF:
goto clpy; // CmmBranch
clpy:
goto shWb; // CmmBranch
shWb:
goto clpH; // CmmBranch
clpH:
goto shWb; // CmmBranch
}
}]
```
Which arose from this STG,
```hs
lvl_rhSw
:: forall a_a99i.
GHC.Generics.U1 a_a99i -> GHC.Generics.U1 [a_a99i]
[GblId,
Arity=1,
Caf=NoCafRefs,
Str=DmdType <L,U>x,
Unf=OtherCon []] =
sat-only \r [eta_shWa]
let-no-escape {
some_v_shWb [Occ=LoopBreaker] :: GHC.Generics.U1 [a12_a99i]
[LclId, Str=DmdType b] =
NO_CCS[] \u [] some_v_shWb;
} in some_v_shWb;
```
Which arose from this Core (from `-ddump-simpl`),
```hs
lvl_rhSw :: forall a_a99i. U1 a_a99i -> U1 [a_a99i]
[GblId, Arity=1, Caf=NoCafRefs, Str=DmdType <L,U>x]
lvl_rhSw =
\ (@ a12_a99i) _ [Occ=Dead] ->
letrec {
some_v_a99l [Occ=LoopBreaker] :: U1 [a12_a99i]
[LclId, Str=DmdType b]
some_v_a99l = some_v_a99l; } in
some_v_a99l
```
Which is apparently the body of the `some` implementation in the `Alternative` instance for `GHC.Generics.U1`.8.0.1erikderikdhttps://gitlab.haskell.org/ghc/ghc/-/issues/11648assertPprPanic, called at compiler/types/TyCoRep.hs:19322019-07-07T18:29:18ZThomas MiedemaassertPprPanic, called at compiler/types/TyCoRep.hs:1932As mentioned in https://mail.haskell.org/pipermail/ghc-devs/2016-February/011455.html, the following tests currently hit an assert when the compiler is built with -DDEBUG:
```
patsyn/should_compile MoreEx [exit code non-0] (normal)
...As mentioned in https://mail.haskell.org/pipermail/ghc-devs/2016-February/011455.html, the following tests currently hit an assert when the compiler is built with -DDEBUG:
```
patsyn/should_compile MoreEx [exit code non-0] (normal)
patsyn/should_compile T11224b [exit code non-0] (normal)
polykinds MonoidsTF [exit code non-0] (normal)
polykinds T11480b [exit code non-0] (normal)
polykinds T11523 [exit code non-0] (normal)
```
```
Compile failed (status 256) errors were:
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20160218 for x86_64-unknown-linux):
ASSERT failed!
CallStack (from HasCallStack):
assertPprPanic, called at compiler/types/TyCoRep.hs:1932:56 in ghc:TyCoRep
checkValidSubst, called at compiler/types/TyCoRep.hs:1991:17 in
ghc:TyCoRep
substTys, called at compiler/types/TyCoRep.hs:2012:14 in ghc:TyCoRep
substTheta, called at compiler/typecheck/TcPatSyn.hs:255:20 in
ghc:TcPatSyn
in_scope InScope {d_ap0 c_apv}
tenv [ap1 :-> c_apv[tau:5]]
tenvFVs [aps :-> t_aps[tau:1], apv :-> c_apv[tau:5]]
cenv []
cenvFVs []
tys []
cos []
```
[D1951](https://phabricator.haskell.org/D1951) contained a stopgap patch, but since it wasn't accepted, I'll just mark the tests as expect_broken for this ticket, so that other developers aren't bothered by this issue.
The offending commit is b5292557dcf2e3844b4837172230575d40a8917e.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"assertPprPanic, called at compiler/types/TyCoRep.hs:1932","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"As mentioned in https://mail.haskell.org/pipermail/ghc-devs/2016-February/011455.html, the following tests currently hit an assert when the compiler is built with -DDEBUG:\r\n\r\n{{{\r\n patsyn/should_compile MoreEx [exit code non-0] (normal)\r\n patsyn/should_compile T11224b [exit code non-0] (normal)\r\n polykinds MonoidsTF [exit code non-0] (normal)\r\n polykinds T11480b [exit code non-0] (normal)\r\n polykinds T11523 [exit code non-0] (normal)\r\n}}}\r\n\r\n{{{\r\nCompile failed (status 256) errors were:\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.1.20160218 for x86_64-unknown-linux):\r\nASSERT failed!\r\n CallStack (from HasCallStack):\r\n assertPprPanic, called at compiler/types/TyCoRep.hs:1932:56 in ghc:TyCoRep\r\n checkValidSubst, called at compiler/types/TyCoRep.hs:1991:17 in\r\nghc:TyCoRep\r\n substTys, called at compiler/types/TyCoRep.hs:2012:14 in ghc:TyCoRep\r\n substTheta, called at compiler/typecheck/TcPatSyn.hs:255:20 in\r\nghc:TcPatSyn\r\n in_scope InScope {d_ap0 c_apv}\r\n tenv [ap1 :-> c_apv[tau:5]]\r\n tenvFVs [aps :-> t_aps[tau:1], apv :-> c_apv[tau:5]]\r\n cenv []\r\n cenvFVs []\r\n tys []\r\n cos []\r\n}}}\r\n\r\nPhab:D1951 contained a stopgap patch, but since it wasn't accepted, I'll just mark the tests as expect_broken for this ticket, so that other developers aren't bothered by this issue.\r\n\r\nThe offending commit is b5292557dcf2e3844b4837172230575d40a8917e.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11644Core lint error in result of Specialise for TEST=T3220 WAY=optasm2019-07-07T18:29:19ZThomas MiedemaCore lint error in result of Specialise for TEST=T3220 WAY=optasmThis is the code:
```hs
{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}
module T3220 where
class Foo m where
type Bar m :: *
action :: m -> Bar m -> m
right x m = action m (Right x)
right' :: (Either a b ~ Bar m, Foo m) =>...This is the code:
```hs
{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}
module T3220 where
class Foo m where
type Bar m :: *
action :: m -> Bar m -> m
right x m = action m (Right x)
right' :: (Either a b ~ Bar m, Foo m) => b -> m -> m
right' x m = action m (Right x)
instance Foo Int where
type Bar Int = Either Int Int
action m a = either (*) (+) a m
instance Foo Float where
type Bar Float = Either Float Float
action m a = either (*) (+) a m
foo = print $ right (1::Int) (3 :: Int)
bar = print $ right (1::Float) (3 :: Float)
```
Invocation:
```
$ ghc-8.0.1 T3220.hs -O -dcore-lint
```
```
[1 of 1] Compiling T3220 ( T3220.hs, T3220.o )
*** Core Lint errors : in result of Specialise ***
<no location info>: warning:
In the expression: action
@ Float
$fFooFloat
m_ayb
((Right @ Float @ Float x_aya)
`cast` (Sub (Sym cobox_aUe) :: Either a_aU3 b_aU4 ~R# Bar m_aU1))
cobox_aUe :: Bar m_aU1 ~# Either a_aU3 b_aU4
[LclId[CoVarId], Str=DmdType] is out of scope
```
Interestingly, with HEAD (2aee41960aa00fe09a2cd1983e02c15e06013037), it hits an assert from #11371.
```
=====> T3220(profasm) 12 of 21 [0, 11, 0]
cd ./indexed-types/should_compile && "/home/thomas/ghc-validate/inplace/test spaces/ghc-stage2" -c T3220.hs -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-warn-tabs -fno-warn-missed-specialisations -fno-ghci-history -O -prof -static -auto-all > T3220.comp.stderr 2>&1
Compile failed (status 256) errors were:
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20160221 for x86_64-unknown-linux):
ASSERT failed!
CallStack (from HasCallStack):
assertPprPanic, called at compiler/types/TyCoRep.hs:1942:51 in ghc:TyCoRep
checkValidSubst, called at compiler/types/TyCoRep.hs:2076:17 in ghc:TyCoRep
substCo, called at compiler/coreSyn/CoreSubst.hs:605:20 in ghc:CoreSubst
in_scope InScope {x_axS m_axT $caction_a1dp $caction_a1dR right
right' foo bar $tcFoo $tc'C:Foo $fFooFloat $fFooInt $trModule
a_s1fZ a_s1g0 a_s1g1 a_s1g2}
tenv [aTT :-> Float, aTV :-> Float, aTW :-> Float]
cenv []
tys []
cos [Sub (Sym cobox_aU6)]
needInScope [aU6 :-> cobox_aU6]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This is a regression from 7.10.3. Setting priority=highest.8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11643Core lint error in simplifier when compiling Rules1 with -O -dcore-lint2019-07-07T18:29:20ZThomas MiedemaCore lint error in simplifier when compiling Rules1 with -O -dcore-lintRunning `make TEST=Rules1 WAY=optasm` results in a core lint error (see attachment) with ghc-8.0.1-rc2.
This is the code:
```hs
{-# LANGUAGE TypeFamilies #-}
module Rules1 where
class C a where
data T a
instance (C a, C b) => C (a...Running `make TEST=Rules1 WAY=optasm` results in a core lint error (see attachment) with ghc-8.0.1-rc2.
This is the code:
```hs
{-# LANGUAGE TypeFamilies #-}
module Rules1 where
class C a where
data T a
instance (C a, C b) => C (a,b) where
data T (a,b) = TPair (T a) (T b)
mapT :: (C a, C b) => (a -> b) -> T a -> T b
{-# NOINLINE mapT #-} -- Otherwwise we get a warning from the rule
mapT = undefined
zipT :: (C a, C b) => T a -> T b -> T (a,b)
{-# NOINLINE [1] zipT #-}
zipT = undefined
{-# RULES
"zipT/mapT" forall f x y.
zipT (mapT f x) y = mapT (\(x,y) -> (f x, y)) (zipT x y)
#-}
```
```
$ ghc-8.0.1 -O Rules1.hs -dcore-lint
```
This is a regression from 7.10.3, and core lint errors are bad, so setting priority to highest.8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11642Heterogeneous type equality evidence ignored2019-07-07T18:29:20ZBen GamariHeterogeneous type equality evidence ignoredEither that or I am missing something...
Consider the following,
```hs
{-# LANGUAGE GADTs, PolyKinds, PatternSynonyms, RankNTypes,
TypeOperators, ViewPatterns #-}
module Test where
data TypeRep (a :: k) where
TypeCon :...Either that or I am missing something...
Consider the following,
```hs
{-# LANGUAGE GADTs, PolyKinds, PatternSynonyms, RankNTypes,
TypeOperators, ViewPatterns #-}
module Test where
data TypeRep (a :: k) where
TypeCon :: String -> TypeRep a
TypeApp :: TypeRep f -> TypeRep x -> TypeRep (f x)
data TypeRepX where
TypeRepX :: TypeRep a -> TypeRepX
data (a :: k1) :~~: (b :: k2) where
HRefl :: a :~~: a
trArrow :: TypeRep (->)
trArrow = undefined
eqTypeRep :: TypeRep (a :: k1) -> TypeRep (b :: k2) -> Maybe (a :~~: b)
eqTypeRep = undefined
typeRepKind :: forall (k :: *). forall (a :: k). TypeRep a -> TypeRep k
typeRepKind = undefined
pattern TRFun :: forall fun. ()
=> forall arg res. (fun ~ (arg -> res))
=> TypeRep arg
-> TypeRep res
-> TypeRep fun
pattern TRFun arg res <- TypeApp (TypeApp (eqTypeRep trArrow -> Just HRefl) arg) res
buildApp :: TypeRepX -> TypeRepX -> TypeRepX
buildApp (TypeRepX f) (TypeRepX x) =
case typeRepKind f of
TRFun arg _ ->
case eqTypeRep arg x of
Just HRefl ->
TypeRepX $ TypeApp f x
```
This fails with,
```
$ ghc Test.hs -fprint-explicit-kinds
[1 of 1] Compiling Test ( Test.hs, Test.o )
Test.hs:38:30: error:
• Expected kind ‘TypeRep (k1 -> res) a’,
but ‘f’ has kind ‘TypeRep k a’
• In the first argument of ‘TypeApp’, namely ‘f’
In the second argument of ‘($)’, namely ‘TypeApp f x’
In the expression: TypeRepX $ TypeApp f x
• Relevant bindings include
arg :: TypeRep * arg (bound at Test.hs:35:11)
```
That is, the typechecker doesn't believe that `f`'s type (why is it saying "kind" here?), `TypeRep k a`, will unify with `TypeRep (k1 -> res) a`, despite the `TRFun` pattern match, which should have brought into scope that `k ~ (arg -> res)`.
This was tested with a recent snapshot from `ghc-8.0` (23baff798aca5856650508ad0f7727045efe3680).
Am I missing something here or is this a bug?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Typechecker doesn't use evidence available from pattern synonym?","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Either that or I am missing something...\r\n\r\nConsider the following,\r\n{{{#!hs\r\n{-# LANGUAGE GADTs, PolyKinds, PatternSynonyms, RankNTypes,\r\n TypeOperators, ViewPatterns #-}\r\n\r\nmodule Test where\r\n\r\ndata TypeRep (a :: k) where\r\n TypeCon :: String -> TypeRep a\r\n TypeApp :: TypeRep f -> TypeRep x -> TypeRep (f x)\r\n\r\ndata TypeRepX where\r\n TypeRepX :: TypeRep a -> TypeRepX\r\n\r\ndata (a :: k1) :~~: (b :: k2) where\r\n HRefl :: a :~~: a\r\n\r\ntrArrow :: TypeRep (->)\r\ntrArrow = undefined\r\n\r\neqTypeRep :: TypeRep (a :: k1) -> TypeRep (b :: k2) -> Maybe (a :~~: b)\r\neqTypeRep = undefined\r\n\r\ntypeRepKind :: forall (k :: *). forall (a :: k). TypeRep a -> TypeRep k\r\ntypeRepKind = undefined\r\n\r\npattern TRFun :: forall fun. ()\r\n => forall arg res. (fun ~ (arg -> res))\r\n => TypeRep arg\r\n -> TypeRep res\r\n -> TypeRep fun\r\npattern TRFun arg res <- TypeApp (TypeApp (eqTypeRep trArrow -> Just HRefl) arg) res\r\n\r\nbuildApp :: TypeRepX -> TypeRepX -> TypeRepX\r\nbuildApp (TypeRepX f) (TypeRepX x) =\r\n case typeRepKind f of\r\n TRFun arg _ ->\r\n case eqTypeRep arg x of\r\n Just HRefl ->\r\n TypeRepX $ TypeApp f x\r\n}}}\r\n\r\nThis fails with,\r\n{{{\r\n$ ghc Test.hs -fprint-explicit-kinds\r\n[1 of 1] Compiling Test ( Test.hs, Test.o )\r\n\r\nTest.hs:38:30: error:\r\n • Expected kind ‘TypeRep (k1 -> res) a’,\r\n but ‘f’ has kind ‘TypeRep k a’\r\n • In the first argument of ‘TypeApp’, namely ‘f’\r\n In the second argument of ‘($)’, namely ‘TypeApp f x’\r\n In the expression: TypeRepX $ TypeApp f x\r\n • Relevant bindings include\r\n arg :: TypeRep * arg (bound at Test.hs:35:11)\r\n}}}\r\n\r\nThat is, the typechecker doesn't believe that `f`'s type (why is it saying \"kind\" here?), `TypeRep k a`, will unify with `TypeRep (k1 -> res) a`, despite the `TRFun` pattern match, which should have brought into scope that `k ~ (arg -> res)`.\r\n\r\nThis was tested with a recent snapshot from `ghc-8.0` (23baff798aca5856650508ad0f7727045efe3680).\r\n\r\nAm I missing something here or is this a bug?","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11624Cannot declare hs-boot declaration if there is already a value in scope2019-07-07T18:29:26ZEdward Z. YangCannot declare hs-boot declaration if there is already a value in scopeThis code no longer works:
```hs
-- A.hs-boot
module A where
concat :: Int -> Int -- overlaps with Prelude's concat
-- B.hs
module B where
import Prelude ()
import {-# SOURCE #-} A
x = concat 3
-- A.hs
module A where
import B
concat n...This code no longer works:
```hs
-- A.hs-boot
module A where
concat :: Int -> Int -- overlaps with Prelude's concat
-- B.hs
module B where
import Prelude ()
import {-# SOURCE #-} A
x = concat 3
-- A.hs
module A where
import B
concat n = n + 2
```
Building `ghc --make A`, this crashes with:
```
[1 of 3] Compiling A[boot] ( A.hs-boot, A.o-boot )
[2 of 3] Compiling B ( B.hs, B.o )
B.hs:4:5: error:
• Can't find interface-file declaration for variable concat
Probable cause: bug in .hi-boot file, or inconsistent .hi file
Use -ddump-if-trace to get an idea of which file caused the error
• In the expression: concat 3
In an equation for ‘x’: x = concat 3
```
The trouble is that renaming has botched up the top-level declaration for boot:
```
ezyang@sabre:~$ ghc-8.0 -c A.hs-boot -ddump-rn -dppr-debug
A.hs-boot:1:1:
==================== Renamer ====================
{A.hs-boot:2:1-20}
base-4.9.0.0:Data.Foldable.concat{v r2S} ::
{A.hs-boot:2:11-20}
ghc-prim-0.5.0.0:GHC.Types.Int{(w) tc 3J}
-> ghc-prim-0.5.0.0:GHC.Types.Int{(w) tc 3J}
```
Is a regression from 7.10. The dodginess is proximal to `renameSig` but I haven't quite narrowed it down yet.8.0.1Edward Z. YangEdward Z. Yanghttps://gitlab.haskell.org/ghc/ghc/-/issues/11614document TypeInType2019-07-07T18:29:36Zrwbartondocument TypeInType(Just to keep track of the status for 8.0.1.)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------- |
| Version | 8.0.1-rc2 |
| Type ...(Just to keep track of the status for 8.0.1.)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------- |
| Version | 8.0.1-rc2 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Documentation |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"document TypeInType","status":"New","operating_system":"","component":"Documentation","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"8.0.1-rc2","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"(Just to keep track of the status for 8.0.1.)","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11608Possible type-checker regression in GHC 8.0 when compiling `microlens`2019-07-07T18:29:37ZHerbert Valerio Riedelhvr@gnu.orgPossible type-checker regression in GHC 8.0 when compiling `microlens`I just updated the GHC 8.0 snapshot I was using from 8.0.0.20160214-g977fb8 to 8.0.0.20160218-g23baff7, and suddenly hackage:microlens-0.4.2.0 fails to build with
```
...
Preprocessing library microlens-0.4.2.0...
[1 of 4] Compiling Len...I just updated the GHC 8.0 snapshot I was using from 8.0.0.20160214-g977fb8 to 8.0.0.20160218-g23baff7, and suddenly hackage:microlens-0.4.2.0 fails to build with
```
...
Preprocessing library microlens-0.4.2.0...
[1 of 4] Compiling Lens.Micro.Type ( src/Lens/Micro/Type.hs, dist/build/Lens/Micro/Type.o )
[2 of 4] Compiling Lens.Micro.Internal ( src/Lens/Micro/Internal.hs, dist/build/Lens/Micro/Internal.o )
src/Lens/Micro/Internal.hs:184:3: error:
• Couldn't match type ‘s’ with ‘g0 a’
‘s’ is untouchable
inside the constraints: (Traversable g,
s ~ g a,
t ~ g b,
Applicative f)
bound by the type signature for:
each :: (Traversable g, s ~ g a, t ~ g b, Applicative f) =>
(a -> f b) -> s -> f t
at src/Lens/Micro/Internal.hs:184:3-27
• In the ambiguity check for ‘each’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the class method:
each :: forall s t a b. Each s t a b => Traversal s t a b
In the class declaration for ‘Each’
```
1. ..is this a regression or a feature? :-)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Possible type-checker regression in GHC 8.0 when compiling `microlens`","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I just updated the GHC 8.0 snapshot I was using from 8.0.0.20160214-g977fb8 to 8.0.0.20160218-g23baff7, and suddenly hackage:microlens-0.4.2.0 fails to build with\r\n\r\n{{{\r\n...\r\nPreprocessing library microlens-0.4.2.0...\r\n[1 of 4] Compiling Lens.Micro.Type ( src/Lens/Micro/Type.hs, dist/build/Lens/Micro/Type.o )\r\n[2 of 4] Compiling Lens.Micro.Internal ( src/Lens/Micro/Internal.hs, dist/build/Lens/Micro/Internal.o )\r\n\r\nsrc/Lens/Micro/Internal.hs:184:3: error:\r\n • Couldn't match type ‘s’ with ‘g0 a’\r\n ‘s’ is untouchable\r\n inside the constraints: (Traversable g,\r\n s ~ g a,\r\n t ~ g b,\r\n Applicative f)\r\n bound by the type signature for:\r\n each :: (Traversable g, s ~ g a, t ~ g b, Applicative f) =>\r\n (a -> f b) -> s -> f t\r\n at src/Lens/Micro/Internal.hs:184:3-27\r\n • In the ambiguity check for ‘each’\r\n To defer the ambiguity check to use sites, enable AllowAmbiguousTypes\r\n When checking the class method:\r\n each :: forall s t a b. Each s t a b => Traversal s t a b\r\n In the class declaration for ‘Each’\r\n}}}\r\n\r\n...is this a regression or a feature? :-)","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/11600Panic (ASSERT failed) in compiler/types/TyCoRep.hs:19392019-07-07T18:29:39ZHerbert Valerio Riedelhvr@gnu.orgPanic (ASSERT failed) in compiler/types/TyCoRep.hs:1939This happens when trying to update the `transformers` submodule to 0.5.2.0 (see `wip/transformers-0.5.2`-branch), then during `validate` the following panic occurs:
```
"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -...This happens when trying to update the `transformers` submodule to 0.5.2.0 (see `wip/transformers-0.5.2`-branch), then during `validate` the following panic occurs:
```
"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -hide-all-packages -i -ighc/. -ighc/stage2/build -ighc/stage2/build/autogen -Ighc/stage2/build -Ighc/stage2/build/autogen -optP-DGHCI -optP-include -optPghc/stage2/build/autogen/cabal_macros.h -package-id array-0.5.1.0 -package-id base-4.9.0.0 -package-id bytestring-0.10.7.0 -package-id containers-0.5.7.1 -package-id deepseq-1.4.2.0 -package-id directory-1.2.5.1 -package-id filepath-1.4.1.0 -package-id ghc-8.1 -package-id ghc-boot-8.1 -package-id ghci-8.1 -package-id haskeline-0.7.2.2 -package-id process-1.4.2.0 -package-id time-1.6 -package-id transformers-0.5.2.0 -package-id unix-2.7.2.0 -Wall -fno-warn-name-shadowing -XHaskell2010 -O -dcore-lint -no-hs-main -threaded -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -odir ghc/stage2/build -hidir ghc/stage2/build -stubdir ghc/stage2/build -c ghc/./GHCi/UI.hs -o ghc/stage2/build/GHCi/UI.dyn_o
WARNING: file compiler/specialise/Specialise.hs, line 1173
Missed specialisation opportunity for $fMonadIOExceptT_$cliftIO
[] 2 [] 1 [ALWAYS]
WARNING: file compiler/specialise/Specialise.hs, line 1173
Missed specialisation opportunity for $w$c<*>
[] 2 [] 1 [0]
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 8.1.20160218 for x86_64-unknown-linux):
ASSERT failed!
file compiler/types/TyCoRep.hs line 1939
in_scope InScope {fromTarget_aiKD pprTT_aj4s pp_resume_aj4J
opts_ajdx flagList_ajdy $dMonad_anX0 $dOrd_areH $dEq_as40
$dRead_as5N $dEq_aswW $dMonadIO_at39 $dApplicative_atce $dShow_atnW
$dMonad_ats4 $dFunctor_atsk $dNFData_awOZ $dEq_azf8 $dFunctor_azfb
$dHasGhciState_azfd $dNFData_aAFw $trModule availableCommands
shortHelpText fullHelpText defPrompt defPrompt2 defaultGhciSettings
ghciWelcomeMsg ghciCommands word_break_chars specials spaces
flagWordBreakChars keepGoing keepGoing' keepGoingPaths
defShortHelpText defFullHelpText findEditor default_progname
default_prompt default_prompt2 interactiveUI
resetLastErrorLocations withGhcAppData runGHCiInput
checkFileAndDirPerms checkPerms incrementLineNo fileLoop mkPrompt
queryQueue installInteractivePrint runCommands runCommands'
runOneCommand checkInputForLayout enqueueCommands runStmt
afterRunStmt runSuccess runAllocs printTypeOfNames compareNames
printTypeOfName lookupCommand' getCurrentBreakSpan
getCurrentBreakModule noArgs withSandboxOnly help info
filterOutChildren pprInfo doWithArgs changeDirectory trySuccess
chooseEditFile defineMacro getGhciStepIO deferredLoad loadModule
loadModule_ reloadModule doLoadAndCollectInfo afterLoad
setContextAfterLoad setContextKeepingPackageModules
keepPackageImports runExceptGhcMonad exceptT parseSpanArg
showSrcSpan showRealSrcSpan kindOfType isSafeModule browseCmd
guessCurrentModule browseModule addModulesToContext
addModulesToContext_ remModulesFromContext setContext addII
restoreContextOnFailure checkAdd setGHCContextFromGHCiState
mkIIDecl iiModules iiModuleName preludeModuleName
implicitPreludeImport isPreludeImport iiSubsumes showOptions
showDynFlags setArgs setProg setEditor setStop setPrompt setPrompt2
setPrompt_ packageFlagsChanged newDynFlags isMinus isPlus setOpt
unsetOpt strToGHCiOpt showImports showModules getLoadedModules
showBindings showBkptTable showContext pprStopped showPackages
showPaths showLanguages showiLanguages showLanguages'
ghciCompleteWord completeGhciCommand completeIdentifier
completeModule listHomeModules completeSetOptions
completeHomeModuleOrFile wrapCompleter wrapIdentCompleter
completeExpression pprintCommand stepCmd leftmostLargestRealSrcSpan
doContinue bold breakSwitch breakByModuleLine breakSyntax
findBreakAndSet findBreakByCoord do_bold start_bold end_bold
listModuleLine listAround getTickArray discardTickArrays
discardActiveBreakPoints turnOffBreak getModBreak handler
showException ghciHandle tryBool lookupModule lookupModuleName
expandPath expandPathIO wantInterpretedModule
wantInterpretedModuleName wantNameFromInterpretedModule
$tc'GhciSettings $tcGhciSettings $tc'GotCommand $tc'BadCommand
$tc'NoLastCommand $tcMaybeCommand a_sKa7 a_sKa8 a_sKa9 a_sKaa
a_sKag a_sKah a_sKai a_sKaj a_sKdg a_sKrw a_sKvG a_sKvH a_sKvI
a_sKwn a_sKwo a_sKws a_sKwt a_sKxU a_sKxV a_sKy8 a_sKy9 a_sKyg
a_sKyh a_sKyk a_sKyl a_sKyV a_sKAe a_sKAk a_sKAl a_sKAm a_sKAn
a_sKAo a_sKAp a_sKAq a_sKAr a_sKAs a_sKAt a_sKAu a_sKD4 a_sKEx
a_sKEy a_sKEz a_sKEA a_sKEB a_sKEC a_sKF1 a_sKF2 a_sKFj a_sKFk
a_sKFm a_sKFn a_sKMd a_sKMe a_sKMf a_sKMg a_sKMh a_sKOX a_sKQx
a_sKQy a_sKTg a_sKWr a_sKWs a_sKWt a_sLrp a_sLrs a_sLrB a_sLs3
a_sLs5 a_sLsd a_sLsV a_sLtg a_sLtY a_sLv2 a_sLv7 a_sLvB a_sLvF
a_sLvP a_sLvT a_sLwI}
tenv [alhH :-> InputT GHCi, alhI :-> e_alhI]
tenvFVs [alhI :-> e_alhI]
cenv []
cenvFVs []
tys []
cos [forall (a17_aDzt :: <*>_N).
<String>_R
-> Sym (N:ExceptT[0] <e_alhI>_N <m_alhH>_R <a17_aDzt>_N)]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
ghc/ghc.mk:112: recipe for target 'ghc/stage2/build/GHCi/UI.dyn_o' failed
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic (ASSERT failed) in compiler/types/TyCoRep.hs:1939","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This happens when trying to update the `transformers` submodule to 0.5.2.0 (see `wip/transformers-0.5.2`-branch), then during `validate` the following panic occurs:\r\n\r\n{{{\r\n\"inplace/bin/ghc-stage1\" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -hide-all-packages -i -ighc/. -ighc/stage2/build -ighc/stage2/build/autogen -Ighc/stage2/build -Ighc/stage2/build/autogen -optP-DGHCI -optP-include -optPghc/stage2/build/autogen/cabal_macros.h -package-id array-0.5.1.0 -package-id base-4.9.0.0 -package-id bytestring-0.10.7.0 -package-id containers-0.5.7.1 -package-id deepseq-1.4.2.0 -package-id directory-1.2.5.1 -package-id filepath-1.4.1.0 -package-id ghc-8.1 -package-id ghc-boot-8.1 -package-id ghci-8.1 -package-id haskeline-0.7.2.2 -package-id process-1.4.2.0 -package-id time-1.6 -package-id transformers-0.5.2.0 -package-id unix-2.7.2.0 -Wall -fno-warn-name-shadowing -XHaskell2010 -O -dcore-lint -no-hs-main -threaded -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -odir ghc/stage2/build -hidir ghc/stage2/build -stubdir ghc/stage2/build -c ghc/./GHCi/UI.hs -o ghc/stage2/build/GHCi/UI.dyn_o \r\nWARNING: file compiler/specialise/Specialise.hs, line 1173\r\n Missed specialisation opportunity for $fMonadIOExceptT_$cliftIO\r\n [] 2 [] 1 [ALWAYS]\r\nWARNING: file compiler/specialise/Specialise.hs, line 1173\r\n Missed specialisation opportunity for $w$c<*>\r\n [] 2 [] 1 [0]\r\nghc-stage1: panic! (the 'impossible' happened)\r\n (GHC version 8.1.20160218 for x86_64-unknown-linux):\r\n\tASSERT failed!\r\n file compiler/types/TyCoRep.hs line 1939\r\n in_scope InScope {fromTarget_aiKD pprTT_aj4s pp_resume_aj4J\r\n opts_ajdx flagList_ajdy $dMonad_anX0 $dOrd_areH $dEq_as40\r\n $dRead_as5N $dEq_aswW $dMonadIO_at39 $dApplicative_atce $dShow_atnW\r\n $dMonad_ats4 $dFunctor_atsk $dNFData_awOZ $dEq_azf8 $dFunctor_azfb\r\n $dHasGhciState_azfd $dNFData_aAFw $trModule availableCommands\r\n shortHelpText fullHelpText defPrompt defPrompt2 defaultGhciSettings\r\n ghciWelcomeMsg ghciCommands word_break_chars specials spaces\r\n flagWordBreakChars keepGoing keepGoing' keepGoingPaths\r\n defShortHelpText defFullHelpText findEditor default_progname\r\n default_prompt default_prompt2 interactiveUI\r\n resetLastErrorLocations withGhcAppData runGHCiInput\r\n checkFileAndDirPerms checkPerms incrementLineNo fileLoop mkPrompt\r\n queryQueue installInteractivePrint runCommands runCommands'\r\n runOneCommand checkInputForLayout enqueueCommands runStmt\r\n afterRunStmt runSuccess runAllocs printTypeOfNames compareNames\r\n printTypeOfName lookupCommand' getCurrentBreakSpan\r\n getCurrentBreakModule noArgs withSandboxOnly help info\r\n filterOutChildren pprInfo doWithArgs changeDirectory trySuccess\r\n chooseEditFile defineMacro getGhciStepIO deferredLoad loadModule\r\n loadModule_ reloadModule doLoadAndCollectInfo afterLoad\r\n setContextAfterLoad setContextKeepingPackageModules\r\n keepPackageImports runExceptGhcMonad exceptT parseSpanArg\r\n showSrcSpan showRealSrcSpan kindOfType isSafeModule browseCmd\r\n guessCurrentModule browseModule addModulesToContext\r\n addModulesToContext_ remModulesFromContext setContext addII\r\n restoreContextOnFailure checkAdd setGHCContextFromGHCiState\r\n mkIIDecl iiModules iiModuleName preludeModuleName\r\n implicitPreludeImport isPreludeImport iiSubsumes showOptions\r\n showDynFlags setArgs setProg setEditor setStop setPrompt setPrompt2\r\n setPrompt_ packageFlagsChanged newDynFlags isMinus isPlus setOpt\r\n unsetOpt strToGHCiOpt showImports showModules getLoadedModules\r\n showBindings showBkptTable showContext pprStopped showPackages\r\n showPaths showLanguages showiLanguages showLanguages'\r\n ghciCompleteWord completeGhciCommand completeIdentifier\r\n completeModule listHomeModules completeSetOptions\r\n completeHomeModuleOrFile wrapCompleter wrapIdentCompleter\r\n completeExpression pprintCommand stepCmd leftmostLargestRealSrcSpan\r\n doContinue bold breakSwitch breakByModuleLine breakSyntax\r\n findBreakAndSet findBreakByCoord do_bold start_bold end_bold\r\n listModuleLine listAround getTickArray discardTickArrays\r\n discardActiveBreakPoints turnOffBreak getModBreak handler\r\n showException ghciHandle tryBool lookupModule lookupModuleName\r\n expandPath expandPathIO wantInterpretedModule\r\n wantInterpretedModuleName wantNameFromInterpretedModule\r\n $tc'GhciSettings $tcGhciSettings $tc'GotCommand $tc'BadCommand\r\n $tc'NoLastCommand $tcMaybeCommand a_sKa7 a_sKa8 a_sKa9 a_sKaa\r\n a_sKag a_sKah a_sKai a_sKaj a_sKdg a_sKrw a_sKvG a_sKvH a_sKvI\r\n a_sKwn a_sKwo a_sKws a_sKwt a_sKxU a_sKxV a_sKy8 a_sKy9 a_sKyg\r\n a_sKyh a_sKyk a_sKyl a_sKyV a_sKAe a_sKAk a_sKAl a_sKAm a_sKAn\r\n a_sKAo a_sKAp a_sKAq a_sKAr a_sKAs a_sKAt a_sKAu a_sKD4 a_sKEx\r\n a_sKEy a_sKEz a_sKEA a_sKEB a_sKEC a_sKF1 a_sKF2 a_sKFj a_sKFk\r\n a_sKFm a_sKFn a_sKMd a_sKMe a_sKMf a_sKMg a_sKMh a_sKOX a_sKQx\r\n a_sKQy a_sKTg a_sKWr a_sKWs a_sKWt a_sLrp a_sLrs a_sLrB a_sLs3\r\n a_sLs5 a_sLsd a_sLsV a_sLtg a_sLtY a_sLv2 a_sLv7 a_sLvB a_sLvF\r\n a_sLvP a_sLvT a_sLwI}\r\n tenv [alhH :-> InputT GHCi, alhI :-> e_alhI]\r\n tenvFVs [alhI :-> e_alhI]\r\n cenv []\r\n cenvFVs []\r\n tys []\r\n cos [forall (a17_aDzt :: <*>_N).\r\n <String>_R\r\n -> Sym (N:ExceptT[0] <e_alhI>_N <m_alhH>_R <a17_aDzt>_N)]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\nghc/ghc.mk:112: recipe for target 'ghc/stage2/build/GHCi/UI.dyn_o' failed\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11597Optimize cmpTypeX2019-07-07T18:29:40ZRichard Eisenbergrae@richarde.devOptimize cmpTypeXSimon and I observed that we could skip the kind-check in `cmpTypeX` if the type has no casts, which is the vastly common case. I will collect this information while checking the type and omit the kind check if possible.
Putting on "hig...Simon and I observed that we could skip the kind-check in `cmpTypeX` if the type has no casts, which is the vastly common case. I will collect this information while checking the type and omit the kind check if possible.
Putting on "highest" priority basically because this is so easy to do.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.3 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Optimize cmpTypeX","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"Simon and I observed that we could skip the kind-check in `cmpTypeX` if the type has no casts, which is the vastly common case. I will collect this information while checking the type and omit the kind check if possible.\r\n\r\nPutting on \"highest\" priority basically because this is so easy to do.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11586GHC 8.0 can't be bootstrapped with GHC 8.02019-07-07T18:29:43ZBen GamariGHC 8.0 can't be bootstrapped with GHC 8.0It seems that GHC 8.0 can't bootstrap itself. With a clean `ghc-8.0` tree and `ghc` from the 8.0.1-rc2 release in `PATH` on x86-64 Debian things fall apart quite quickly,
```
$ ghc -V
The Glorious Glasgow Haskell Compilation System, ver...It seems that GHC 8.0 can't bootstrap itself. With a clean `ghc-8.0` tree and `ghc` from the 8.0.1-rc2 release in `PATH` on x86-64 Debian things fall apart quite quickly,
```
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 8.0.0.20160204
$ ./boot
$ ./configure
$ make -j2
+ test -f mk/config.mk.old
+ cmp -s mk/config.mk mk/config.mk.old
+ cp -p mk/config.mk mk/config.mk.old
touch -r mk/config.mk.old mk/config.mk
+ test -f mk/project.mk.old
+ cmp -s mk/project.mk mk/project.mk.old
touch -r mk/project.mk.old mk/project.mk
+ test -f compiler/ghc.cabal.old
+ cmp -s compiler/ghc.cabal compiler/ghc.cabal.old
touch -r compiler/ghc.cabal.old compiler/ghc.cabal
===--- building phase 0
make --no-print-directory -f ghc.mk phase=0 phase_0_builds
"rm" -f compiler/stage1/build/Config.hs
"inplace/bin/ghc-cabal" configure libraries/ghc-boot dist-boot "" --with-ghc="/opt/exp/ghc/roots/8.0.1-rc2/bin/ghc" --with-ghc-pkg="/opt/exp/ghc/roots/8.0.1-rc2/bin/ghc-pkg" --package-db=/opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf --disable-library-for-ghci --enable-library-vanilla --disable-library-profiling --disable-shared --with-hscolour="/home/ben/.cabal/bin/HsColour" --configure-option=CFLAGS="-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline" --configure-option=LDFLAGS=" " --configure-option=CPPFLAGS=" " --gcc-options="-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline " --constraint "binary == 0.8.2.0" --constraint "Cabal == 1.23.1.0" --constraint "hpc == 0.6.0.3" --constraint "ghc-boot == 8.0.0.20160211" --constraint "hoopl == 3.10.2.1" --constraint "transformers == 0.5.1.0" --constraint "template-haskell == 2.11.0.0" --constraint "terminfo == 0.4.0.2" --with-gcc="/usr/bin/gcc" --with-ar="/usr/bin/ar" --with-alex="/home/ben/.cabal/bin/alex" --with-happy="/home/ben/.cabal/bin/happy"
Creating compiler/stage1/build/Config.hs ...
Configuring ghc-boot-8.0.0.20160211...
done.
ghc-cabal: ghc-pkg dump failed
libraries/ghc-boot/ghc.mk:3: recipe for target 'libraries/ghc-boot/dist-boot/package-data.mk' failed
make[1]: *** [libraries/ghc-boot/dist-boot/package-data.mk] Error 1
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
```
In particular the failing command is
```
$ /opt/exp/ghc/roots/8.0.1-rc2/bin/ghc-pkg dump --package-db=/opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf -v2
GHC package manager version 8.0.0.20160204
Timestamp 2016-02-12 09:21:06.076187903 UTC for /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache
Timestamp 2016-02-12 09:21:06.076187903 UTC for /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf (same as cache)
using cache: /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache
ghc-pkg: /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Build System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ezyang |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC 8.0 can't be bootstrapped with GHC 8.0","status":"New","operating_system":"","component":"Build System","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ezyang"],"type":"Bug","description":"It seems that GHC 8.0 can't bootstrap itself. With a clean `ghc-8.0` tree and `ghc` from the 8.0.1-rc2 release in `PATH` on x86-64 Debian things fall apart quite quickly,\r\n{{{\r\n$ ghc -V\r\nThe Glorious Glasgow Haskell Compilation System, version 8.0.0.20160204\r\n$ ./boot\r\n$ ./configure\r\n$ make -j2\r\n+ test -f mk/config.mk.old\r\n+ cmp -s mk/config.mk mk/config.mk.old\r\n+ cp -p mk/config.mk mk/config.mk.old\r\ntouch -r mk/config.mk.old mk/config.mk\r\n+ test -f mk/project.mk.old\r\n+ cmp -s mk/project.mk mk/project.mk.old\r\ntouch -r mk/project.mk.old mk/project.mk\r\n+ test -f compiler/ghc.cabal.old\r\n+ cmp -s compiler/ghc.cabal compiler/ghc.cabal.old\r\ntouch -r compiler/ghc.cabal.old compiler/ghc.cabal\r\n===--- building phase 0\r\nmake --no-print-directory -f ghc.mk phase=0 phase_0_builds\r\n\"rm\" -f compiler/stage1/build/Config.hs \r\n\"inplace/bin/ghc-cabal\" configure libraries/ghc-boot dist-boot \"\" --with-ghc=\"/opt/exp/ghc/roots/8.0.1-rc2/bin/ghc\" --with-ghc-pkg=\"/opt/exp/ghc/roots/8.0.1-rc2/bin/ghc-pkg\" --package-db=/opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf --disable-library-for-ghci --enable-library-vanilla --disable-library-profiling --disable-shared --with-hscolour=\"/home/ben/.cabal/bin/HsColour\" --configure-option=CFLAGS=\"-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline\" --configure-option=LDFLAGS=\" \" --configure-option=CPPFLAGS=\" \" --gcc-options=\"-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline \" --constraint \"binary == 0.8.2.0\" --constraint \"Cabal == 1.23.1.0\" --constraint \"hpc == 0.6.0.3\" --constraint \"ghc-boot == 8.0.0.20160211\" --constraint \"hoopl == 3.10.2.1\" --constraint \"transformers == 0.5.1.0\" --constraint \"template-haskell == 2.11.0.0\" --constraint \"terminfo == 0.4.0.2\" --with-gcc=\"/usr/bin/gcc\" --with-ar=\"/usr/bin/ar\" --with-alex=\"/home/ben/.cabal/bin/alex\" --with-happy=\"/home/ben/.cabal/bin/happy\"\r\nCreating compiler/stage1/build/Config.hs ... \r\nConfiguring ghc-boot-8.0.0.20160211...\r\ndone.\r\nghc-cabal: ghc-pkg dump failed\r\nlibraries/ghc-boot/ghc.mk:3: recipe for target 'libraries/ghc-boot/dist-boot/package-data.mk' failed\r\nmake[1]: *** [libraries/ghc-boot/dist-boot/package-data.mk] Error 1\r\nMakefile:129: recipe for target 'all' failed\r\nmake: *** [all] Error 2\r\n}}}\r\n\r\nIn particular the failing command is\r\n{{{\r\n$ /opt/exp/ghc/roots/8.0.1-rc2/bin/ghc-pkg dump --package-db=/opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf -v2\r\nGHC package manager version 8.0.0.20160204\r\nTimestamp 2016-02-12 09:21:06.076187903 UTC for /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache\r\nTimestamp 2016-02-12 09:21:06.076187903 UTC for /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf (same as cache)\r\nusing cache: /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache\r\nghc-pkg: /opt/exp/ghc/ghc-8.0/libraries/bootstrapping.conf/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11572BangPatterns-related behavior regressions on GHC 8.02019-07-07T18:29:46ZRyan ScottBangPatterns-related behavior regressions on GHC 8.0When you compile this code:
```hs
{-# LANGUAGE BangPatterns #-}
main :: IO ()
main = let !_ = (undefined :: ()) in print 2
```
with GHC 8.0.1-rc2 with any level of optimizations, it will print `2` instead of throwing `undefined` like ...When you compile this code:
```hs
{-# LANGUAGE BangPatterns #-}
main :: IO ()
main = let !_ = (undefined :: ()) in print 2
```
with GHC 8.0.1-rc2 with any level of optimizations, it will print `2` instead of throwing `undefined` like GHC 7.10.3 does.
Note that changing `undefined :: ()` to something like `undefined :: Int#` is enough to invoke `undefined` when compiled, but if you run this code in GHCi:
```
λ> :set -XMagicHash -XBangPatterns
λ> import GHC.Prim
λ> let !_ = (undefined :: Int#) in print 2
```
You get something even stranger:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.0.20160204 for x86_64-unknown-linux):
dsLet: unlifted
!_ = (undefined :: Int#)
print @ Integer $dShow_a2ky 2
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"BangPatterns-related behavior regressions on GHC 8.0","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When you compile this code:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE BangPatterns #-}\r\n\r\nmain :: IO ()\r\nmain = let !_ = (undefined :: ()) in print 2\r\n}}}\r\n\r\nwith GHC 8.0.1-rc2 with any level of optimizations, it will print `2` instead of throwing `undefined` like GHC 7.10.3 does.\r\n\r\nNote that changing `undefined :: ()` to something like `undefined :: Int#` is enough to invoke `undefined` when compiled, but if you run this code in GHCi:\r\n\r\n{{{\r\nλ> :set -XMagicHash -XBangPatterns\r\nλ> import GHC.Prim\r\nλ> let !_ = (undefined :: Int#) in print 2\r\n}}}\r\n\r\nYou get something even stranger:\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.0.20160204 for x86_64-unknown-linux):\r\n dsLet: unlifted\r\n !_ = (undefined :: Int#)\r\n print @ Integer $dShow_a2ky 2\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11558Using Cabal 1.22 against GHC 8.0 results in unhelpful errors2019-07-07T18:29:49ZBen GamariUsing Cabal 1.22 against GHC 8.0 results in unhelpful errorsGHC 8.0 will require Cabal \>1.22 due to a variety of interface changes (see #10714, [D1780](https://phabricator.haskell.org/D1780), https://mail.haskell.org/pipermail/ghc-devs/2016-January/010978.html). Unfortunately things currently bl...GHC 8.0 will require Cabal \>1.22 due to a variety of interface changes (see #10714, [D1780](https://phabricator.haskell.org/D1780), https://mail.haskell.org/pipermail/ghc-devs/2016-January/010978.html). Unfortunately things currently blow up late in compilation with a seemingly unrelated error when this requirement isn't met. Namely, we complain about bad interface files for dependencies. For instance,
```
Text/Parsec/Prim.hs:85:1: error:
Bad interface file: /root/.cabal/lib/x86_64-linux-ghc-8.0.0.20160204/mtl-2.2.1-9wMhzcfsAXi7cNtl9n7svO/Control/Monad/Cont/Class.hi
Something is amiss; requested module mtl-2.2.1@mtl-2.2.1-1af5dabd2d7abb688f2145aec87badc4:Control.Monad.Cont.Class differs from name found in the interface file mtl_9wMhzcfsAXi7cNtl9n7svO:Control.Monad.Cont.Class
```
# For users seeing this error
The solution here is to install `Cabal` 1.23 or later and a `cabal-install` linking against it. Currently this requires installing `Cabal` and `cabal-install` from git. This is most easily done using GHC 7.10. Finally, you need to clear your package database.
This can be done with,
```
$ git clone git://github.com/haskell/cabal
$ cd cabal
$ cabal update
$ cabal install Cabal/ cabal-install/
$ rm -R $HOME/.ghc/*-8.0.0*
```8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11555catch _|_ breaks at -O12020-04-02T11:39:30ZSergei Trofimovichcatch _|_ breaks at -O1Discovered on xmonad-0.12 test failure.
Happens on today's -HEAD and ghc-8.0.1-rc1,-rc2
Short example is (needs only base):
```hs
-- cat F.hs
module F where
import qualified Control.Exception as C
import System.IO.Unsafe
import qualif...Discovered on xmonad-0.12 test failure.
Happens on today's -HEAD and ghc-8.0.1-rc1,-rc2
Short example is (needs only base):
```hs
-- cat F.hs
module F where
import qualified Control.Exception as C
import System.IO.Unsafe
import qualified Data.List as L
abort :: String -> a
abort x = error $ "xmonad: StackSet: " ++ x
prop_abort x = unsafePerformIO $ C.catch (abort "fail")
(\(C.SomeException e) ->
return $ "xmonad: StackSet: fail" `L.isPrefixOf` show e )
where
_ = x :: Int
```
Session 1 \[ok\]:
```
$ ghci F.hs
GHCi, version 8.0.0.20160204: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling F ( F.hs, interpreted )
Ok, modules loaded: F.
*F> prop_abort 1
True
```
Session 2 \[fails\]:
```
$ ghci -O1 -fobject-code F.hs
GHCi, version 8.0.0.20160204: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling F ( F.hs, F.o )
Ok, modules loaded: F.
Prelude F> prop_abort 1
*** Exception: xmonad: StackSet: fail
CallStack (from HasCallStack):
error, called at F.hs:9:11 in main:F
```
I would expect exception to be caught on both cases.
Is it unreasonable expectation in light of unsafePerformIO?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | simonpj |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"catch under unsafePerformIO breaks on -O1","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["simonpj"],"type":"Bug","description":"Discovered on xmonad-0.12 test failure.\r\nHappens on today's -HEAD and ghc-8.0.1-rc1,-rc2\r\n\r\nShort example is (needs only base):\r\n{{{#!hs\r\n-- cat F.hs\r\nmodule F where\r\n\r\nimport qualified Control.Exception as C\r\nimport System.IO.Unsafe\r\nimport qualified Data.List as L\r\n\r\nabort :: String -> a\r\nabort x = error $ \"xmonad: StackSet: \" ++ x\r\n\r\nprop_abort x = unsafePerformIO $ C.catch (abort \"fail\")\r\n (\\(C.SomeException e) ->\r\n return $ \"xmonad: StackSet: fail\" `L.isPrefixOf` show e )\r\n where\r\n _ = x :: Int\r\n}}}\r\n\r\nSession 1 [ok]:\r\n{{{\r\n$ ghci F.hs\r\n\r\nGHCi, version 8.0.0.20160204: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling F ( F.hs, interpreted )\r\nOk, modules loaded: F.\r\n\r\n*F> prop_abort 1\r\nTrue\r\n}}}\r\n\r\nSession 2 [fails]:\r\n{{{\r\n$ ghci -O1 -fobject-code F.hs\r\n\r\nGHCi, version 8.0.0.20160204: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling F ( F.hs, F.o )\r\nOk, modules loaded: F.\r\n\r\nPrelude F> prop_abort 1\r\n*** Exception: xmonad: StackSet: fail\r\nCallStack (from HasCallStack):\r\n error, called at F.hs:9:11 in main:F\r\n}}}\r\n\r\nI would expect exception to be caught on both cases.\r\nIs it unreasonable expectation in light of unsafePerformIO?\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11520GHC falls into a hole if given incorrect kind signature2019-07-07T18:30:05ZBen GamariGHC falls into a hole if given incorrect kind signatureIf one provides an incorrect kind signature GHC throws up. For instance, this non-sense,
```hs
{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-}
module Play where
import GHC.Types hiding (TyCon)
data ...If one provides an incorrect kind signature GHC throws up. For instance, this non-sense,
```hs
{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-}
module Play where
import GHC.Types hiding (TyCon)
data TypeRep (a :: k)
class Typeable k => Typeable (a :: k) where
typeRep :: TypeRep a
data Compose (f :: k1 -> *) (g :: k2 -> k1) (a :: k2) = Compose (f (g a))
-- Note how the kind signature on g is incorrect
instance (Typeable f, Typeable (g :: k), Typeable k) => Typeable (Compose f g) where
typeRep = undefined
```
fails with
```
λ> :load Bug.hs
[1 of 1] Compiling Play ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.1.20160122 for x86_64-unknown-linux):
fvProv falls into a hole {abet}
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11487stg_ap_pp_fast doesn't pass the argument in the arity=1 case2019-07-07T18:30:13Zrwbartonstg_ap_pp_fast doesn't pass the argument in the arity=1 caseThe body of `stg_ap_pp_fast` looks like
```
arity = TO_W_(StgFunInfoExtra_arity(%GET_FUN_INFO(R1)));
ASSERT(arity > 0);
if (arity == 1) {
Sp_adj(-2);
W_[Sp+WDS(1)] = R3...The body of `stg_ap_pp_fast` looks like
```
arity = TO_W_(StgFunInfoExtra_arity(%GET_FUN_INFO(R1)));
ASSERT(arity > 0);
if (arity == 1) {
Sp_adj(-2);
W_[Sp+WDS(1)] = R3;
W_[Sp+WDS(0)] = stg_ap_p_info;
R1 = R1 + 1;
jump_SAVE_CCCS(%GET_ENTRY(UNTAG(R1)));
}
if (arity == 2) {
Sp_adj(0);
R1 = R1 + 2;
jump %GET_ENTRY(UNTAG(R1)) [R1,R2,R3];
} else {
Sp_adj(-3);
W_[Sp+WDS(2)] = R3;
W_[Sp+WDS(1)] = R2;
if (arity < 4) {
R1 = R1 + arity;
}
BUILD_PAP(2,2,stg_ap_pp_info,FUN);
}
```
where
```
// Jump to target, saving CCCS and restoring it on return
#if defined(PROFILING)
#define jump_SAVE_CCCS(target) \
Sp(-1) = CCCS; \
Sp(-2) = stg_restore_cccs_info; \
Sp_adj(-2); \
jump (target) [R1]
#else
#define jump_SAVE_CCCS(target) jump (target) [R1]
#endif
```
So in the arity=1 case the jump amounts to
```
jump (%GET_ENTRY(UNTAG(R1))) [R1]
```
R1 is the function to apply, but we don't pass its argument, R2!
Now, possibly by design, the calling convention of `stg_ap_pp_fast` is such that the first argument to apply is in R2, which is the same register that the function R1 will expect to find its argument in. So if nothing happens to disturb R2 (and possibly this is always the case with the NCG), then everything is fine. However, it's definitely not fine for the LLVM backend, which quite reasonably passes `undef` for the R2, R3, and R4 arguments when doing the jump. On arm/Android, LLVM decided to clobber `r8` (the physical register for R2) in the body of `stg_ap_ppp_fast` (which has the same problems as `stg_ap_pp_fast`).
This caused a crash for the following program:
```
main = print (read "3"::Int)
```
when built with `-debug`.
This appears to have been broken by commit f9265dd369b9e269349930012c25e670248f2a09 which changed the argument list for `jump_SAVE_CCCS` from `[*]` to `[R1]`.8.0.1gmainlandgmainland