GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2022-10-16T00:01:57Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/21301compiler exception when using empty case in Arrow notation2022-10-16T00:01:57ZJakob Brünkercompiler exception when using empty case in Arrow notation## Summary
```
ghci> :set -XArrows -XLambdaCase
ghci> (proc x -> case () of) 4
*** Exception: foldb of empty list
CallStack (from HasCallStack):
error, called at compiler/GHC/HsToCore/Arrows.hs:1201:14 in ghc:GHC.HsToCore.Arrows
```
...## Summary
```
ghci> :set -XArrows -XLambdaCase
ghci> (proc x -> case () of) 4
*** Exception: foldb of empty list
CallStack (from HasCallStack):
error, called at compiler/GHC/HsToCore/Arrows.hs:1201:14 in ghc:GHC.HsToCore.Arrows
```
## Expected behavior
Runtime exception (non-exhaustive patterns) rather than compiler exception
## Environment
* GHC version used: 9.2.1Jakob BrünkerJakob Brünkerhttps://gitlab.haskell.org/ghc/ghc/-/issues/21265winery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)2022-03-26T17:38:23ZRyan Scottwinery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)_(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7..._(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7a8e5b19f6661f4925bde. Here is a minimized example:
```hs
{-# LANGUAGE RankNTypes #-}
module Codec.Winery.Class (extractorProduct') where
class GSerialiseProduct f where
dummy :: f x -> ()
productExtractor :: TransFusion [] ((->) Bool) (f Int)
extractorProduct' :: GSerialiseProduct f => Maybe (f Int)
extractorProduct' = unTransFusion productExtractor go
go :: f x -> Maybe (g x)
go _ = Nothing
newtype TransFusion f g a = TransFusion { unTransFusion :: forall h. Applicative h => (forall x. f x -> h (g x)) -> h a }
```
```
$ ~/Software/ghc-9.3.20220316/bin/ghc Bug.hs -O -fforce-recomp
[1 of 1] Compiling Codec.Winery.Class ( Bug.hs, Bug.o )
<no location info>: error:
expectJust isRecDataCon:go_tc_app
CallStack (from HasCallStack):
error, called at compiler/GHC/Data/Maybe.hs:71:27 in ghc:GHC.Data.Maybe
expectJust, called at compiler/GHC/Core/Opt/WorkWrap/Utils.hs:1348:25 in ghc:GHC.Core.Opt.WorkWrap.Utils
```
This regression was introduced in commit 8ff32124c8cd37050f3dc7cbb32b8d41711ebcaf (`DmdAnal: Don't unbox recursive data types`). cc @sgraf8129.4.1Sebastian GrafSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/21250ghc: panic! (the 'impossible' happened)2023-11-07T15:19:22Zanuytsghc: panic! (the 'impossible' happened)## Summary
GHC asks me to report a bug.
## Steps to reproduce
Trying to install Agda v2.5.1 using the Haskell Tool Stack:
```
git clone git@github.com:agda/agda.git agda-2.5.1
cd agda-2.5.1
git checkout v2.5.1.2.20161216
stack --stack-...## Summary
GHC asks me to report a bug.
## Steps to reproduce
Trying to install Agda v2.5.1 using the Haskell Tool Stack:
```
git clone git@github.com:agda/agda.git agda-2.5.1
cd agda-2.5.1
git checkout v2.5.1.2.20161216
stack --stack-yaml stack-8.0.1.yaml install
```
## Expected behavior
Assuming that the bug is there, for me it outputs the following message:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
Prelude.chr: bad argument: 2600468483
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-- While building simple Setup.hs (scroll up to its section to see the error) using:
/home/<username>/.stack/programs/x86_64-linux/ghc-tinfo6-8.0.1/bin/ghc-8.0.1 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-1.24.0.0 /home/<username>/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/<username>/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/<username>/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1
Process exited with code: ExitFailure 1
```
Ideally it would just install Agda of course.
## Environment
* GHC version used: 8.0.1 I suppose.
Optional:
* Operating System: Ubuntu 21.04 (Kubuntu)
* System Architecture:https://gitlab.haskell.org/ghc/ghc/-/issues/21186zlib test suite segfaults on HEAD2022-03-18T09:20:45ZRyan Scottzlib test suite segfaults on HEADTo reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id...To reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id (standard): OK (0.43s)
+++ OK, passed 100 tests; 124 discarded.
decompress . compress = id (Zlib -> GZipOrZLib): OK (0.37s)
+++ OK, passed 100 tests; 140 discarded.
decompress . compress = id (GZip -> GZipOrZlib): OK (0.34s)
+++ OK, passed 100 tests; 64 discarded.
concatenated gzip members: OK (0.36s)
+++ OK, passed 100 tests; 88 discarded.
multiple gzip members, boundaries (all 2-chunks): OK (0.02s)
+++ OK, passed 100 tests.
multiple gzip members, boundaries (all 3-chunks): Segmentation fault (core dumped)
```
I haven't had an opportunity to minimize the issue, but for the time being, all of the dependencies build on HEAD.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21130mkCoCast panic in 9.22022-05-20T09:55:47ZKrzysztof GogolewskimkCoCast panic in 9.2The following file causes a panic in 9.2.1 and on the `ghc-9.2` branch
```haskell
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module M where
type family Item l
type instance Item [a] = a
f :: Enum (Item l) => l
f = f
x = (_ f) ::...The following file causes a panic in 9.2.1 and on the `ghc-9.2` branch
```haskell
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module M where
type family Item l
type instance Item [a] = a
f :: Enum (Item l) => l
f = f
x = (_ f) :: Int
```
```
(GHC version 9.2.0.20220224:
mkCoCast
(Enum (Sym (D:R:Item[][0] <Char>_N)))_R
Enum Char ~ Enum (Item [Char])
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Coercion.hs:1675:5 in ghc:GHC.Core.Coercion
```
HEAD is good:
```
M.hs:10:6: error:
• Found hole: _ :: t0 -> Int
Where: ‘t0’ is an ambiguous type variable
```
I haven't checked which commit fixed it. There are no other tickets mentioning `mkCoCast`, so I think it's worth checking if the bug is actually fixed or merely hidden.
Credits to Dominic Steinitz for the initial report.9.2.2Ben Gamarisheafsam.derbyshire@gmail.comBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21122Rule let-matching logic fails to extend in-scope set correctly2022-02-26T02:46:48ZBen GamariRule let-matching logic fails to extend in-scope set correctly`Note [Matching lets]` in `GHC.Core.Rules` claims the following:
> We use `GHC.Core.Subst.substBind` to freshen the binding, using an in-scope set that is the original in-scope variables plus the `rs_bndrs` (currently floated let-bindin...`Note [Matching lets]` in `GHC.Core.Rules` claims the following:
> We use `GHC.Core.Subst.substBind` to freshen the binding, using an in-scope set that is the original in-scope variables plus the `rs_bndrs` (currently floated let-bindings). So in (a) above we'll freshen the `v` binding; in (b) above we'll freshen the *second* `v` binding.
However, this isn't what `match` actually does. Specifically, it fails to extend the in-scope set of the substitution given to `substBind` with `rs_bndrs`:
```haskell
match renv subst e1 (Let bind e2) mco
| -- pprTrace "match:Let" (vcat [ppr bind, ppr $ okToFloat (rv_lcl renv) (bindFreeVars bind)]) $
not (isJoinBind bind) -- can't float join point out of argument position
, okToFloat (rv_lcl renv) (bindFreeVars bind) -- See Note [Matching lets]
= match (renv { rv_fltR = flt_subst'
, rv_lcl = rv_lcl renv `extendRnInScopeSetList` new_bndrs })
-- We are floating the let-binding out, as if it had enclosed
-- the entire target from Day 1. So we must add its binders to
-- the in-scope set (#20200)
(subst { rs_binds = rs_binds subst . Let bind'
, rs_bndrs = new_bndrs ++ rs_bndrs subst })
e1 e2 mco
| otherwise
= Nothing
where
(flt_subst', bind') = substBind (rv_fltR renv) bind
new_bndrs = bindersOf bind'
```
Now, one might be tempted to think that this is okay; afterall, `match` *does* extend `rv_fltR` of the `RuleMatchEnv`. However, `match_exprs` does not propagate `RuleMatchEnv` across matched arguments; only the `RuleSubst` will be carried over when we match the next argument.
I don't yet know why we haven't observed fallout from this `master`, but this seems like a bug which resulted in Core Lint failures while building `Data.Binary.Class` on the 9.2 branch (see !7602).Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21118InScope ASSERT failure with break0062022-02-23T14:10:21ZMatthew PickeringInScope ASSERT failure with break006```
+panic! (the 'impossible' happened)
+ GHC version 9.3.20220221:
+ ASSERT failed!
+ in_scope InScope {wild_00}
+ tenv [ams :-> LiftedRep, amt :-> LiftedRep, amu :-> a_I16g[rt],
+ amv :-> ()]
+ tenvFVs {a_I16g[rt]}
+ cenv [...```
+panic! (the 'impossible' happened)
+ GHC version 9.3.20220221:
+ ASSERT failed!
+ in_scope InScope {wild_00}
+ tenv [ams :-> LiftedRep, amt :-> LiftedRep, amu :-> a_I16g[rt],
+ amv :-> ()]
+ tenvFVs {a_I16g[rt]}
+ cenv []
+ cenvFVs {}
+ tys [q_ams]
+ cos []
+ Call stack:
+ CallStack (from HasCallStack):
+ assertPpr, called at compiler/GHC/Core/TyCo/Subst.hs:<line>:<column> in <package-id>:GHC.Core.TyCo.Subst
+ checkValidSubst, called at compiler/GHC/Core/TyCo/Subst.hs:<line>:<column> in <package-id>:GHC.Core.TyCo.Subst
+ substTy, called at compiler/GHC/Core/Opt/Simplify/Env.hs:<line>:<column> in <package-id>:GHC.Core.Opt.Simplify.Env
```
Related to #21113https://gitlab.haskell.org/ghc/ghc/-/issues/21080Panic in `lookupIdSubst` when making ModDetails/ModIface by hand2022-03-15T01:47:15ZGergő ÉrdiPanic in `lookupIdSubst` when making ModDetails/ModIface by handI'm synthesizing a `ModDetails`/`ModIface` directly without any original Haskell source code, and running into a problem where GHC fails during `Core` generation with an internal panic. Also, note the warning (when GHC is compiled with `...I'm synthesizing a `ModDetails`/`ModIface` directly without any original Haskell source code, and running into a problem where GHC fails during `Core` generation with an internal panic. Also, note the warning (when GHC is compiled with `-DDEBUG`) that also only shows up when the instance is used:
```
Loading module Class
Registering module Class
Registering module Enums
Loading module A
Registering module A
WARNING:
Glomming in A: [EeR :-> Once1]
Call stack:
CallStack (from HasCallStack):
warnPprTrace, called at compiler/GHC/Core/Opt/OccurAnal.hs:85:5 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.Opt.OccurAnal
hello: panic! (the 'impossible' happened)
GHC version 9.3.20211130:
lookupIdSubst
$fMyClassFoo
InScope {}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Subst.hs:260:17 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.Subst
lookupIdSubst, called at compiler/GHC/Core/SimpleOpt.hs:240:10 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.SimpleOpt
simple_opt_expr, called at compiler/GHC/Core/SimpleOpt.hs:225:5 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.SimpleOpt
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
To reproduce:
1. Put attached [`Class.hs`](/uploads/a169537e55c9d38ecba15bec8be30a51/Class.hs) and [`A.hs`](/uploads/ce3d33e1eb981c405b9703bb63a4df08/A.hs) files into `input/` directory
2. Edit line 48 of `Main.hs` to point to your Hadrian stage1 directory
3. Run [`Main.hs`](/uploads/3b76b1f06548482a143f1070c495fb29/Main.hs) and observe the error messageMatthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/20969Panic in the Template Haskell2023-08-22T07:58:11ZDavid FeuerPanic in the Template Haskell## Summary
Write a brief description of the issue.
## Steps to reproduce
Write a module like this
```haskell
{-# language TemplateHaskellQuotes #-}
module SequenceCode where
import Data.Sequence.Internal
import qualified Language.Has...## Summary
Write a brief description of the issue.
## Steps to reproduce
Write a module like this
```haskell
{-# language TemplateHaskellQuotes #-}
module SequenceCode where
import Data.Sequence.Internal
import qualified Language.Haskell.TH.Syntax as TH
class Functor t => SequenceCode t where
traverseCode :: TH.Quote m => (a -> TH.Code m b) -> t a -> TH.Code m (t b)
traverseCode f = sequenceCode . fmap f
sequenceCode :: TH.Quote m => t (TH.Code m a) -> TH.Code m (t a)
sequenceCode = traverseCode id
instance SequenceCode Seq where
sequenceCode (Seq t) = [|| Seq $$(traverseCode sequenceCode t) ||]
instance SequenceCode Elem where
sequenceCode (Elem t) = [|| Elem $$t ||]
instance SequenceCode FingerTree where
sequenceCode (Deep s pr m sf) =
[|| Deep s $$(sequenceCode pr) $$(traverseCode sequenceCode m) $$(sequenceCode sf) ||]
sequenceCode (Single a) = [|| Single $$a ||]
sequenceCode EmptyT = [|| EmptyT ||]
instance SequenceCode Digit where
sequenceCode (One a) = [|| One $$a ||]
sequenceCode (Two a b) = [|| Two $$a $$b ||]
sequenceCode (Three a b c) = [|| Three $$a $$b $$c ||]
sequenceCode (Four a b c d) = [|| Four $$a $$b $$c $$d ||]
instance SequenceCode Node where
sequenceCode (Node2 s x y) = [|| Node2 s $$x $$y ||]
sequenceCode (Node3 s x y z) = [|| Node3 s $$x $$y $$z ||]
```
Then write another one importing it and doing thus:
```haskell
{-# LANGUAGE TemplateHaskell, ScopedTypeVariables #-}
glumber :: forall a. Num a => a -> Seq a
glumber x = $$(sequenceCode (fromList [TH.liftTyped _ :: TH.Code TH.Q a, [||x||]]))
```
Result:
```haskell
tests/seq-properties.hs:974:40: error:
• No instance for (TH.Lift a) arising from a use of ‘TH.liftTyped’
• In the expression: TH.liftTyped _ :: TH.Code TH.Q a
In the first argument of ‘fromList’, namely
‘[TH.liftTyped _ :: TH.Code TH.Q a, [|| x ||]]’
In the first argument of ‘sequenceCode’, namely
‘(fromList [TH.liftTyped _ :: TH.Code TH.Q a, [|| x ||]])’
|
974 | glumber x = $$(sequenceCode (fromList [TH.liftTyped _ :: TH.Code TH.Q a, [||x||]]))
| ^^^^^^^^^^^^
tests/seq-properties.hs:974:53: error:ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
No skolem info:
[a_aaba[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Tc/Errors.hs:2888:17 in ghc:GHC.Tc.Errors
```
## Expected behavior
I expect my error messages not to be accompanied by panics.
## Environment
* GHC version used: 9.2.1
Optional:
* Operating System:
* System Architecture:Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/20965Applying -dannot-lint to GHC itself causes a panic2022-03-03T08:52:01ZMatthew PickeringApplying -dannot-lint to GHC itself causes a panicI tried building with:
hadrian.settings
```
stage1.ghc.ghc.hs.opts += -dcore-lint -dannot-lint
```
with build command
```
./hadrian/build --flavour=perf+ipe -j4 --freeze1 --build-root=_build-perf
```
Leads to error:
```
ghc: panic!...I tried building with:
hadrian.settings
```
stage1.ghc.ghc.hs.opts += -dcore-lint -dannot-lint
```
with build command
```
./hadrian/build --flavour=perf+ipe -j4 --freeze1 --build-root=_build-perf
```
Leads to error:
```
ghc: panic! (the 'impossible' happened)
GHC version 9.3.20220119:
idInfo
m_a1bv
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Types/Var.hs:786:34 in ghc:GHC.Types.Var
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/20908Panic "Can't find slot" while building primitive-unlifted with 9.0.22022-10-18T20:42:30ZZubinPanic "Can't find slot" while building primitive-unlifted with 9.0.2```
$ git clone https://github.com/haskell-primitive/primitive-unlifted
$ cd primitive-unlifted
$ git checkout a896a0ed1a9801fce8c7b49bd2aca9a71a0dd861
$ cabal build -w ghc-9.0.2 --allow-newer
[ 7 of 18] Compiling Data.Primitive.Unlifted...```
$ git clone https://github.com/haskell-primitive/primitive-unlifted
$ cd primitive-unlifted
$ git checkout a896a0ed1a9801fce8c7b49bd2aca9a71a0dd861
$ cabal build -w ghc-9.0.2 --allow-newer
[ 7 of 18] Compiling Data.Primitive.Unlifted.MVar.Primops ( src/Data/Primitive/Unlifted/MVar/Primops.hs, /home/zubin/primitive-unlifted/dist-newstyle/build/x86_64-linux/ghc-9.0.2/primitive-unlifted-1.0.0.0/build/Data/Primitive/Unlifted/MVar/Primops.o, /home/zubin/primitive-unlifted/dist-newstyle/build/x86_64-linux/ghc-9.0.2/primitive-unlifted-1.0.0.0/build/Data/Primitive/Unlifted/MVar/Primops.dyn_o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.2:
findSlot
Can't find slot
[PtrUnliftedSlot]
[PtrLiftedSlot]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Types/RepType.hs:217:9 in ghc:GHC.Types.RepType
```https://gitlab.haskell.org/ghc/ghc/-/issues/20820Mysterious RULES-related(?) panic with 9.2.12022-05-25T11:12:38ZMatthew Cravenclyring@gmail.comMysterious RULES-related(?) panic with 9.2.1While working on [this bytestring pull request](https://github.com/haskell/bytestring/pull/443), one of my changes caused GHC 9.2.1 to mysteriously panic instead of successfully compiling the Data.ByteString.Internal module, as witnessed...While working on [this bytestring pull request](https://github.com/haskell/bytestring/pull/443), one of my changes caused GHC 9.2.1 to mysteriously panic instead of successfully compiling the Data.ByteString.Internal module, as witnessed by my local testing and [this CI run](https://github.com/haskell/bytestring/runs/4499515980).
## Steps to reproduce
Compiling this file [Internal.hs](/uploads/117ffbc345ec23c9383f378094ffdf1c/Internal.hs) with GHC 9.2.1 produces the following error message:
<details><summary>Click to expand</summary>
```
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
refineFromInScope
InScope {wild_00 $dIP_a16J $cp1Monoid_a16N $cmempty_a16P
$cmappend_a16X $cmconcat_a174 $c<>_a17c $csconcat_a17j $krep_a18N
concat stimesPolymorphic stimesInt $tc'BS $tcByteString
$fMonoidByteString $fSemigroupByteString $trModule $dIP_s19g}
$dMonoid_a15E
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
</details>
## Environment
* GHC version used: 9.2.1
* Operating System: WSL v2 on Windows 10
* System Architecture: x86-649.2.3Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/20747thread blocked indefinitely in an MVar operation2022-02-17T05:24:39ZJohan Josefssonthread blocked indefinitely in an MVar operation## Summary
Write a brief description of the issue.
I got this message:
*Main>
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64-unknown-linux):
thread blocked indefinitely in an MVar operation
Please re...## Summary
Write a brief description of the issue.
I got this message:
*Main>
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64-unknown-linux):
thread blocked indefinitely in an MVar operation
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
## Steps to reproduce
Please provide a set of concrete steps to reproduce the issue.
I had been fiddling around for a while. The only code loaded was:
-----------
```hs
factors n = [x | x <- [1..n], mod n x == 0]
isPrime n = (length (factors n)) == 2
primeFactors n = filter isPrime (factors n)
primeFactorized :: Integral a => a -> [a]
primeFactorized n
| n == 1 = []
| otherwise = x:primeFactorized (div n x) where x = (last (primeFactors n))
```
-------------
This is what I issued and what I got:
```
*Main>
*Main>
*Main> primeFactorized (3*3*3*31*37*37*83)
[83,37,37,31,3,3,3]
*Main>
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64-unknown-linux):
thread blocked indefinitely in an MVar operation
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
## Expected behavior
What do you expect the reproducer described above to do?
## Environment
* GHC version used:
Optional:
* Operating System:
* System Architecture:https://gitlab.haskell.org/ghc/ghc/-/issues/20689Linker error when using ghci (packman) - requires dynamic R_X86_64_PC32 reloc...2021-12-28T09:48:09ZMatthew PickeringLinker error when using ghci (packman) - requires dynamic R_X86_64_PC32 reloc against 'g0' which may overflow at runtimeRepro: git@github.com:mpickering/packman.git
```
cabal repl
cabal repl
```
```
[nix-shell:~/packman]$ cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details)...Repro: git@github.com:mpickering/packman.git
```
cabal repl
cabal repl
```
```
[nix-shell:~/packman]$ cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- packman-0.5.0 (lib) (first run)
Configuring library for packman-0.5.0..
Preprocessing library for packman-0.5.0..
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
[1 of 4] Compiling GHC.Packing.PackException ( /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-8.10.2/packman-0.5.0/build/GHC/Packing/PackException.hs, /run/user/1000/ghc1380672_0/ghc_8.o )
[2 of 4] Compiling GHC.Packing.Type ( GHC/Packing/Type.hs, /run/user/1000/ghc1380672_0/ghc_10.o )
[3 of 4] Compiling GHC.Packing.Core ( GHC/Packing/Core.hs, /run/user/1000/ghc1380672_0/ghc_6.o )
[4 of 4] Compiling GHC.Packing ( GHC/Packing.hs, interpreted )
Ok, four modules loaded.
*GHC.Packing> :q
Leaving GHCi.
^[[A
[nix-shell:~/packman]$ cabal repl
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- packman-0.5.0 (lib) (first run)
Preprocessing library for packman-0.5.0..
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
/nix/store/p792j5f44l3f0xi7ai5jllwnxqwnka88-binutils-2.31.1/bin/ld.gold: error: /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-8.10.2/packman-0.5.0/build/cbits/Wrapper.o: requires dynamic R_X86_64_PC32 reloc against 'g0' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
cabal: repl failed for packman-0.5.0.
```
You need to `cabal build` then `cabal repl` for this to fail on HEAD.
```
[nix-shell:~/packman]$ cabal build -w ~/ghc-multi-hmi/_build/stage1/bin/ghc
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.2.0.0 supports
'ghc' version < 8.12): /home/matt/ghc-multi-hmi/_build/stage1/bin/ghc is
version 9.3.20211107
Resolving dependencies...
Build profile: -w ghc-9.3.20211107 -O1
In order, the following will be built (use -v for more details):
- packman-0.5.0 (lib) (first run)
Configuring library for packman-0.5.0..
Preprocessing library for packman-0.5.0..
Building library for packman-0.5.0..
[1 of 4] Compiling GHC.Packing.PackException ( /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/PackException.hs, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/PackException.o, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/PackException.dyn_o )
[2 of 4] Compiling GHC.Packing.Type ( GHC/Packing/Type.hs, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/Type.o, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/Type.dyn_o )
[3 of 4] Compiling GHC.Packing.Core ( GHC/Packing/Core.hs, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/Core.o, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing/Core.dyn_o )
[4 of 4] Compiling GHC.Packing ( GHC/Packing.hs, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing.o, /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/GHC/Packing.dyn_o )
[nix-shell:~/packman]$ cabal repl -w ~/ghc-multi-hmi/_build/stage1/bin/ghc
Build profile: -w ghc-9.3.20211107 -O1
In order, the following will be built (use -v for more details):
- packman-0.5.0 (lib) (ephemeral targets)
Preprocessing library for packman-0.5.0..
GHCi, version 9.3.20211107: https://www.haskell.org/ghc/ :? for help
/nix/store/p792j5f44l3f0xi7ai5jllwnxqwnka88-binutils-2.31.1/bin/ld.gold: error: /home/matt/packman/dist-newstyle/build/x86_64-linux/ghc-9.3.20211107/packman-0.5.0/build/cbits/Wrapper.o: requires dynamic R_X86_64_PC32 reloc against 'g0' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
cabal: repl failed for packman-0.5.0.
```
It's strange that you need to run `cabal repl` twice in order to see the issue. I can see this with 8.10.2 and also HEAD.Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/20680Panic: No skolem info when DerivingVia levity-polymorphic class2022-01-29T16:06:57ZchessaiPanic: No skolem info when DerivingVia levity-polymorphic classI am using GHC 9.2.1 on NixOS.
Minimal repro:
```
❯ cat Main.hs
{-# language
DerivingStrategies
, DerivingVia
, GeneralisedNewtypeDeriving
, StandaloneDeriving
#-}
module Main (main) where
import GHC.Exts (TYPE)
import GHC.G...I am using GHC 9.2.1 on NixOS.
Minimal repro:
```
❯ cat Main.hs
{-# language
DerivingStrategies
, DerivingVia
, GeneralisedNewtypeDeriving
, StandaloneDeriving
#-}
module Main (main) where
import GHC.Exts (TYPE)
import GHC.Generics (Rec1)
import Data.Kind (Type)
main :: IO ()
main = pure ()
class FunctorL (f :: Type -> TYPE r) where
fmapL :: (a -> b) -> (f a -> f b)
newtype Base1 f a = Base1 { getBase1 :: f a }
deriving newtype (Functor)
instance Functor f => FunctorL (Base1 f) where
fmapL = fmap
deriving via (Base1 (Rec1 f)) instance FunctorL (Rec1 f)
❯ ghc Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:26:50: error:ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210821:
No skolem info:
[k_a1aN]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Tc/Errors.hs:2888:17 in ghc:GHC.Tc.Errors
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
I think this has something to do with the poly-kindedness of Rec1.
cc @Icelandjack @RyanGlScottRichard Eisenbergrae@richarde.devsheafsam.derbyshire@gmail.comRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/20673aarch64 compilation error2021-11-15T08:24:38ZGeorge Thomasaarch64 compilation errorThis is the simplest example I could reproduce with. In particular, it matters that `Trans` and `runTrans` are in different modules, and that we use `-O1`.
Code below can also be found [on GitHub](https://github.com/georgefst/clark/tree...This is the simplest example I could reproduce with. In particular, it matters that `Trans` and `runTrans` are in different modules, and that we use `-O1`.
Code below can also be found [on GitHub](https://github.com/georgefst/clark/tree/ghc-bug). The same issue exists on `master` at 81cb08e (and most previous commits) but that's a lot more complex.
Compiler was built with `ghcup compile ghc -v 9.2.1 -b 8.10.7 -x aarch64-none-linux-gnu -c $(pwd)/build.mk` on an x86_64 Manjaro Linux host, using the `gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz` toolchain from [the official ARM distribution](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads).
`build.mk`:
```
V=0
BUILD_MAN = NO
BUILD_SPHINX_HTML = NO
BUILD_SPHINX_PDF = NO
Stage1Only = YES
HADDOCK_DOCS = NO
BuildFlavour = quick
WITH_TERMINFO = NO
BIGNUM_BACKEND = native
```
`Main.hs`:
```
import Control.Monad
import Control.Monad.Except
import Control.Monad.State
import Control.Monad.Trans.Maybe
import Lib
main :: IO ()
main = go ()
where
go () =
maybe (go ()) pure
=<< runTrans
( (\() -> void $ liftIO $ pure ())
=<< liftIO (pure ())
)
runTrans :: Trans IO a -> IO (Maybe a)
runTrans (Trans x) = runMaybeT $ evalStateT x ()
```
`Lib.hs`
```
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Lib where
import Control.Monad.Except
import Control.Monad.State
import Control.Monad.Trans.Maybe
newtype Trans m a
= Trans
( StateT
()
( MaybeT
m
)
a
)
deriving newtype
( Functor
, Applicative
, Monad
, MonadIO
)
```
Log:
```
$ aarch64-none-linux-gnu-ghc-9.2.1 -O1 Main.hs -outputdir dist
[1 of 2] Compiling Lib ( Lib.hs, dist/Lib.o )
[2 of 2] Compiling Main ( Main.hs, dist/Main.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
refineFromInScope
InScope {wild_00 main eta_B0 wild_X1E wild_a15Z y_a161 ds1_a1IJ
ipv_a1IK ipv1_a1IL ds_d1I4 main $trModule main_s2pH $trModule_s2pI
$trModule_s2pJ $trModule_s2pK $trModule_s2pL go_s2pM main_s2pN
lvl_s2pO lvl_s2pP lvl_s2pQ lvl_s2pR lvl_s2pS lvl_s2pT $j_s2pW}
s'_a16E
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
Verbose log:
```
$ aarch64-none-linux-gnu-ghc-9.2.1 -O1 Main.hs -outputdir dist -v
Glasgow Haskell Compiler, Version 9.2.1, stage 1 booted by GHC version 8.10.7
*** initializing unit database:
Using binary package database: /home/gthomas/.ghcup/ghc/aarch64-none-linux-gnu-9.2.1/lib/aarch64-none-linux-gnu-ghc-9.2.1/package.conf.d/package.cache
package flags []
loading package database /home/gthomas/.ghcup/ghc/aarch64-none-linux-gnu-9.2.1/lib/aarch64-none-linux-gnu-ghc-9.2.1/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.8.0
wired-in package ghc-bignum mapped to ghc-bignum-1.2
wired-in package base mapped to base-4.16.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.18.0.0
wired-in package ghc not found.
!!! initializing unit database: finished in 21.95 milliseconds, allocated 3.741 megabytes
*** initializing unit database:
package flags []
loading package database /home/gthomas/.ghcup/ghc/aarch64-none-linux-gnu-9.2.1/lib/aarch64-none-linux-gnu-ghc-9.2.1/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.8.0
wired-in package ghc-bignum mapped to ghc-bignum-1.2
wired-in package base mapped to base-4.16.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.18.0.0
wired-in package ghc not found.
!!! initializing unit database: finished in 2.68 milliseconds, allocated 2.055 megabytes
*** Chasing dependencies:
Chasing modules from: Main.hs
!!! Chasing dependencies: finished in 2.27 milliseconds, allocated 2.021 megabytes
Stable obj: {}
Stable BCO: {}
Ready for upsweep
[NONREC
ModSummary {
ms_hs_date = 2021-11-12 13:31:42.396878746 UTC
ms_mod = Lib,
ms_textual_imps = [(Nothing, Prelude),
(Nothing, Control.Monad.Trans.Maybe),
(Nothing, Control.Monad.State), (Nothing, Control.Monad.Except)]
ms_srcimps = []
} [],
NONREC
ModSummary {
ms_hs_date = 2021-11-12 13:36:22.614284008 UTC
ms_mod = Main,
ms_textual_imps = [(Nothing, Prelude), (Nothing, Lib),
(Nothing, Control.Monad.Trans.Maybe),
(Nothing, Control.Monad.State), (Nothing, Control.Monad.Except),
(Nothing, Control.Monad)]
ms_srcimps = []
} []]
*** Deleting temp files:
Deleting:
compile: input file ./Lib.hs
*** Checking old interface for Lib (use -ddump-hi-diffs for more details):
[1 of 2] Compiling Lib ( Lib.hs, dist/Lib.o )
*** Parser [Lib]:
!!! Parser [Lib]: finished in 0.41 milliseconds, allocated 0.607 megabytes
*** Renamer/typechecker [Lib]:
!!! Renamer/typechecker [Lib]: finished in 52.34 milliseconds, allocated 28.821 megabytes
*** Desugar [Lib]:
Result size of Desugar (before optimization)
= {terms: 406, types: 1,422, coercions: 456, joins: 0/58}
Result size of Desugar (after optimization)
= {terms: 242, types: 472, coercions: 154, joins: 0/0}
!!! Desugar [Lib]: finished in 4.81 milliseconds, allocated 5.071 megabytes
*** Simplifier [Lib]:
Result size of Simplifier iteration=1
= {terms: 368, types: 763, coercions: 548, joins: 0/12}
Result size of Simplifier iteration=2
= {terms: 337, types: 634, coercions: 343, joins: 0/7}
Result size of Simplifier
= {terms: 333, types: 610, coercions: 274, joins: 0/7}
!!! Simplifier [Lib]: finished in 6.59 milliseconds, allocated 8.722 megabytes
*** Specialise [Lib]:
Result size of Specialise
= {terms: 333, types: 610, coercions: 274, joins: 0/7}
!!! Specialise [Lib]: finished in 0.30 milliseconds, allocated 0.465 megabytes
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Lib]:
Result size of Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False})
= {terms: 335, types: 615, coercions: 274, joins: 0/8}
!!! Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Lib]: finished in 1.20 milliseconds, allocated 1.314 megabytes
*** Simplifier [Lib]:
Result size of Simplifier iteration=1
= {terms: 479, types: 961, coercions: 326, joins: 0/19}
Result size of Simplifier iteration=2
= {terms: 455, types: 893, coercions: 366, joins: 0/11}
Result size of Simplifier iteration=3
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
Result size of Simplifier
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
!!! Simplifier [Lib]: finished in 8.09 milliseconds, allocated 7.957 megabytes
*** Simplifier [Lib]:
Result size of Simplifier
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
!!! Simplifier [Lib]: finished in 1.80 milliseconds, allocated 1.811 megabytes
*** Simplifier [Lib]:
Result size of Simplifier
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
!!! Simplifier [Lib]: finished in 1.51 milliseconds, allocated 1.811 megabytes
*** Float inwards [Lib]:
Result size of Float inwards
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
!!! Float inwards [Lib]: finished in 0.29 milliseconds, allocated 0.634 megabytes
*** Called arity analysis [Lib]:
Result size of Called arity analysis
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
!!! Called arity analysis [Lib]: finished in 0.46 milliseconds, allocated 0.378 megabytes
*** Simplifier [Lib]:
Result size of Simplifier iteration=1
= {terms: 451, types: 883, coercions: 352, joins: 0/9}
Result size of Simplifier
= {terms: 445, types: 881, coercions: 352, joins: 0/9}
!!! Simplifier [Lib]: finished in 20.99 milliseconds, allocated 3.610 megabytes
*** Demand analysis [Lib]:
Result size of Demand analysis
= {terms: 445, types: 881, coercions: 352, joins: 0/9}
!!! Demand analysis [Lib]: finished in 0.67 milliseconds, allocated 1.069 megabytes
*** Constructed Product Result analysis [Lib]:
Result size of Constructed Product Result analysis
= {terms: 445, types: 881, coercions: 352, joins: 0/9}
!!! Constructed Product Result analysis [Lib]: finished in 0.31 milliseconds, allocated 0.263 megabytes
*** Worker Wrapper binds [Lib]:
Result size of Worker Wrapper binds
= {terms: 462, types: 932, coercions: 352, joins: 0/13}
!!! Worker Wrapper binds [Lib]: finished in 0.17 milliseconds, allocated 0.153 megabytes
*** Simplifier [Lib]:
Result size of Simplifier iteration=1
= {terms: 456, types: 926, coercions: 352, joins: 0/11}
Result size of Simplifier
= {terms: 444, types: 903, coercions: 352, joins: 0/8}
!!! Simplifier [Lib]: finished in 4.45 milliseconds, allocated 4.173 megabytes
*** Exitification transformation [Lib]:
Result size of Exitification transformation
= {terms: 444, types: 903, coercions: 352, joins: 0/8}
!!! Exitification transformation [Lib]: finished in 0.08 milliseconds, allocated 0.117 megabytes
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = True}) [Lib]:
Result size of Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = True})
= {terms: 456, types: 938, coercions: 352, joins: 0/12}
!!! Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = True}) [Lib]: finished in 1.50 milliseconds, allocated 2.020 megabytes
*** Common sub-expression [Lib]:
Result size of Common sub-expression
= {terms: 450, types: 920, coercions: 352, joins: 0/12}
!!! Common sub-expression [Lib]: finished in 0.49 milliseconds, allocated 0.634 megabytes
*** Float inwards [Lib]:
Result size of Float inwards
= {terms: 446, types: 910, coercions: 352, joins: 0/10}
!!! Float inwards [Lib]: finished in 0.37 milliseconds, allocated 0.630 megabytes
*** Simplifier [Lib]:
Result size of Simplifier iteration=1
= {terms: 444, types: 908, coercions: 352, joins: 0/10}
Result size of Simplifier
= {terms: 444, types: 908, coercions: 352, joins: 0/10}
!!! Simplifier [Lib]: finished in 4.05 milliseconds, allocated 4.074 megabytes
*** Demand analysis [Lib]:
Result size of Demand analysis
= {terms: 444, types: 908, coercions: 352, joins: 0/10}
!!! Demand analysis [Lib]: finished in 0.78 milliseconds, allocated 1.146 megabytes
*** CoreTidy [Lib]:
Result size of Tidy Core
= {terms: 444, types: 908, coercions: 352, joins: 0/10}
!!! CoreTidy [Lib]: finished in 0.87 milliseconds, allocated 1.005 megabytes
Created temporary directory: /tmp/ghc123636_0
*** CorePrep [Lib]:
Result size of CorePrep
= {terms: 625, types: 1,303, coercions: 352, joins: 0/76}
!!! CorePrep [Lib]: finished in 1.28 milliseconds, allocated 1.811 megabytes
*** CoreToStg [Lib]:
*** Stg2Stg:
!!! CoreToStg [Lib]: finished in 1.93 milliseconds, allocated 0.683 megabytes
*** CodeGen [Lib]:
!!! CodeGen [Lib]: finished in 21.35 milliseconds, allocated 34.237 megabytes
*** WriteIface [dist/Lib.hi]:
writeBinIface: 55 Names
writeBinIface: 128 dict entries
!!! WriteIface [dist/Lib.hi]: finished in 1.16 milliseconds, allocated 1.247 megabytes
*** systool:as:
*** Assembler:
aarch64-none-linux-gnu-gcc -iquote. -Idist -no-pie -fPIC -U__PIC__ -D__PIC__ -x assembler -c /tmp/ghc123636_0/ghc_2.s -o dist/Lib.o.tmp
!!! systool:as: finished in 0.42 milliseconds, allocated 0.118 megabytes
*** Deleting temp files:
Deleting: /tmp/ghc123636_0/ghc_1.s /tmp/ghc123636_0/ghc_2.s /tmp/ghc123636_0/ghc_3.c
Warning: deleting non-existent /tmp/ghc123636_0/ghc_1.s
Warning: deleting non-existent /tmp/ghc123636_0/ghc_3.c
compile: input file Main.hs
*** Checking old interface for Main (use -ddump-hi-diffs for more details):
[2 of 2] Compiling Main ( Main.hs, dist/Main.o )
*** Parser [Main]:
!!! Parser [Main]: finished in 0.39 milliseconds, allocated 0.574 megabytes
*** Renamer/typechecker [Main]:
!!! Renamer/typechecker [Main]: finished in 3.86 milliseconds, allocated 3.005 megabytes
*** Desugar [Main]:
Result size of Desugar (before optimization)
= {terms: 86, types: 118, coercions: 3, joins: 0/15}
Result size of Desugar (after optimization)
= {terms: 66, types: 93, coercions: 3, joins: 0/5}
!!! Desugar [Main]: finished in 1.02 milliseconds, allocated 1.158 megabytes
*** Simplifier [Main]:
Result size of Simplifier iteration=1
= {terms: 192, types: 402, coercions: 220, joins: 0/4}
Result size of Simplifier iteration=2
= {terms: 117, types: 236, coercions: 116, joins: 0/0}
Result size of Simplifier iteration=3
= {terms: 119, types: 246, coercions: 125, joins: 0/0}
Result size of Simplifier
= {terms: 117, types: 243, coercions: 119, joins: 0/0}
!!! Simplifier [Main]: finished in 18.27 milliseconds, allocated 17.439 megabytes
*** Specialise [Main]:
Result size of Specialise
= {terms: 117, types: 243, coercions: 119, joins: 0/0}
!!! Specialise [Main]: finished in 0.22 milliseconds, allocated 0.174 megabytes
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Main]:
Result size of Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False})
= {terms: 129, types: 311, coercions: 119, joins: 0/0}
!!! Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Main]: finished in 1.04 milliseconds, allocated 0.531 megabytes
*** Simplifier [Main]:
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting: /tmp/ghc123636_0
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
refineFromInScope
InScope {wild_00 main eta_B0 wild_X1E wild_a15Z y_a161 ds1_a1IK
ipv_a1IL ipv1_a1IM ds_d1I5 main $trModule main_s2pI $trModule_s2pJ
$trModule_s2pK $trModule_s2pL $trModule_s2pM go_s2pN main_s2pO
lvl_s2pP lvl_s2pQ lvl_s2pR lvl_s2pS lvl_s2pT lvl_s2pU $j_s2pX}
s'_a16E
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```https://gitlab.haskell.org/ghc/ghc/-/issues/20639panic in refineFromInScope with 9.2.12022-03-31T02:23:24Zquarkpanic in refineFromInScope with 9.2.1## Summary
The [Bluespec Compiler (BSC)](https://github.com/B-Lang-org/bsc) has been compiling with GHC 9.0.1, 8.10.7, etc, but when attempting to compile with 9.2.1, it encounters a panic in `refineFromInScope`. I have reduced it to a...## Summary
The [Bluespec Compiler (BSC)](https://github.com/B-Lang-org/bsc) has been compiling with GHC 9.0.1, 8.10.7, etc, but when attempting to compile with 9.2.1, it encounters a panic in `refineFromInScope`. I have reduced it to a small example, which compiles fine when GHC is called with no flags, but encounters the panic when called with `-O2`:
```
$ ghc -O2 CtxRed.hs
[1 of 1] Compiling CtxRed ( CtxRed.hs, CtxRed.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
refineFromInScope
InScope {wild_00 wild_X1 s1_X4 d_aF3 incoh_aF4 cpreds_aF5
$cctxRed_aJC $krep_aKv $krep_aKw $krep_aKx $krep_aKy $krep_aKz
$krep_aKA $krep_aKB $krep_aKC $krep_aKD $krep_aKE $krep_aKF
$krep_aKG $krep_aKH $krep_aKI $krep_aKJ $krep_aKK $krep_aKL
$krep_aKM $krep_aKN $krep_aKO $krep_aKP $krep_aKQ $krep_aKR
wild_aPf x_aPi s1_aPv wild_aPx a1_aPy s'_aPz ctxRedCQType'
$tc'CTypeclass $tcCTypeclass $tc'CPred $tcCPred $tc'CQType
$tcCQType $tc'Cclass $tcCDefn $tcCtxRed $tc'C:CtxRed $fCtxRedCDefn
$trModule $trModule_sN7 $trModule_sN8 $trModule_sN9 $trModule_sNa
$krep_sNb $krep_sNc $krep_sNd $krep_sNe $krep_sNf $krep_sNg
$krep_sNh $krep_sNi $krep_sNj $krep_sNk $tcCTypeclass_sNl
$tcCTypeclass_sNm $tc'CTypeclass_sNn $tc'CTypeclass_sNo
$tcCPred_sNp $tcCPred_sNq $tc'CPred_sNr $tc'CPred_sNs $krep_sNt
$tcCQType_sNu $tcCQType_sNv $tc'CQType_sNw $tc'CQType_sNx
$tcCDefn_sNy $tcCDefn_sNz $tc'Cclass_sNA $tc'Cclass_sNB
$tcCtxRed_sNC $tcCtxRed_sND $krep_sNE $tc'C:CtxRed_sNF
$tc'C:CtxRed_sNG ds_sPV m1_sPW lvl_sQ4 lvl_sQ5 m1_sQ7 lvl_sQ8}
s'_X7
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
```
I do not know if this is related to the two other issues that mention a panic in `refineFromInScope` (#20419 and #19360).
## Steps to reproduce
Place the following example in a file called `CtxRed.hs`:
```
module CtxRed(ctxRedCQType', CtxRed(..)) where
import Control.Monad.State
import Control.Monad.Except
type TI = StateT Bool (ExceptT [Integer] (State Bool))
data CDefn = Cclass (Maybe Bool) [CPred]
data CQType = CQType [CPred]
data CTypeclass = CTypeclass
data CPred = CPred CTypeclass
class CtxRed a where
ctxRed :: a -> TI a
instance CtxRed CDefn where
ctxRed d@(Cclass incoh cpreds) = do
(CQType _) <- ctxRedCQType' (CQType [])
return (Cclass incoh cpreds)
ctxRedCQType' :: CQType -> TI (CQType)
ctxRedCQType' cqt = do
let CQType cqs = cqt
case [p | p@(CPred CTypeclass) <- cqs] of
p : _ -> return ()
[] -> return ()
return (cqt)
```
And execute:
```
ghc -O2 CtxRed.hs
```
If you would like to reproduce the original error in BSC (which has 226 Haskell source files, imported foreign functions, etc), instructions for building BSC can be found at https://github.com/B-Lang-org/bsc/blob/main/INSTALL.md
## Expected behavior
If I execute GHC without the `-O2` flag, or if I use a version such as 9.0.1 or 8.10.7, there are no errors or warnings:
```
$ ghc CtxRed.hs
[1 of 1] Compiling CtxRed ( CtxRed.hs, CtxRed.o )
```
This small example has no real meaning; in the BSC project, with the original `CtxRed.hs` file, the module compiles and GHC continues compiling the rest of the modules and generates an executable, which can then be run against the BSC testsuite.
## Environment
As said above, this occurs with GHC 9.2.1.
The small example was developed on macOS 11.6. The original BSC issue can be seen both on GitHub's Ubuntu 18.04/20.04 VMs (in the BSC project's automated testing) and locally for me on macOS 11.6.9.2.2https://gitlab.haskell.org/ghc/ghc/-/issues/20636Invalid transformation around division constant folding2022-03-07T23:27:05ZBen GamariInvalid transformation around division constant foldingCompiling this Cmm program with `-O1` and GHC 8.10.7
```c
test ( bits64 buffer ) {
bits64 ret;
(ret) = prim %popcnt8(%divu(bits8[buffer + (0 :: bits64)], (2 :: bits8)));
return (ret);
}
```
Results in a `-dcmm-lint` failure:
```
C...Compiling this Cmm program with `-O1` and GHC 8.10.7
```c
test ( bits64 buffer ) {
bits64 ret;
(ret) = prim %popcnt8(%divu(bits8[buffer + (0 :: bits64)], (2 :: bits8)));
return (ret);
}
```
Results in a `-dcmm-lint` failure:
```
Cmm lint error:
in basic block c4
in MachOp application:
I8[R1] >> 1 :: W8
op is expecting: [W8, W64]
arguments provide: [I8, I8]
Program was:
{offset
c4: // global
//tick src<hi.cmm:(1,24)-(5,1)>
(_c2::I64) = call MO_PopCnt W8(I8[R1] >> 1 :: W8);
R1 = _c2::I64;
call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
}
```https://gitlab.haskell.org/ghc/ghc/-/issues/20567ghc-stage2 internal error on RiscV64 platform.2021-11-06T04:14:34Zkgardasghc-stage2 internal error on RiscV64 platform.## Summary
Build of HEAD fails due to ghc-stage2 internal error on RiscV64 platform.
## Steps to reproduce
Obtain qemu-system-riscv64 (tested 5.1.0, 5.2.0, 6.1.0 here), make it working with OpenSuSE Thumbleweed image https://en.opensu...## Summary
Build of HEAD fails due to ghc-stage2 internal error on RiscV64 platform.
## Steps to reproduce
Obtain qemu-system-riscv64 (tested 5.1.0, 5.2.0, 6.1.0 here), make it working with OpenSuSE Thumbleweed image https://en.opensuse.org/openSUSE:RISC-V. This is so far the only linux image which provides registerised ghc 8.10.x. Try to build GHC HEAD with it. The build fails here with:
```
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -O0 -H64m -Wall -hide-all-packages -package-env - -i -iutils/check-ppr/. -iutils/check-ppr/dist-install/build -Iutils/check-ppr/dist-install/build -iutils/check-ppr/dist-install/build/check-ppr/autogen -Iutils/check-ppr/dist-install/build/check-ppr/autogen -optP-include -optPutils/check-ppr/dist-install/build/check-ppr/autogen/cabal_macros.h -package-id base-4.16.0.0 -package-id bytestring-0.11.1.0 -package-id containers-0.6.4.1 -package-id directory-1.3.6.1 -package-id filepath-1.4.2.1 -package-id ghc-9.3 -Wall -XHaskell2010 -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -outputdir utils/check-ppr/dist-install/build -c utils/check-ppr/./Main.hs -o utils/check-ppr/dist-install/build/Main.dyn_o
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -O0 -H64m -Wall -hide-all-packages -package-env - -i -iutils/check-exact/. -iutils/check-exact/dist-install/build -Iutils/check-exact/dist-install/build -iutils/check-exact/dist-install/build/check-exact/autogen -Iutils/check-exact/dist-install/build/check-exact/autogen -optP-include -optPutils/check-exact/dist-install/build/check-exact/autogen/cabal_macros.h -package-id base-4.16.0.0 -package-id bytestring-0.11.1.0 -package-id containers-0.6.4.1 -package-id directory-1.3.6.1 -package-id filepath-1.4.2.1 -package-id ghc-9.3 -package-id ghc-boot-9.3 -package-id mtl-2.2.2 -Wall -XHaskell2010 -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -outputdir utils/check-exact/dist-install/build -c utils/check-exact/./Types.hs -o utils/check-exact/dist-install/build/Types.dyn_o
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -O0 -H64m -Wall -hide-all-packages -package-env - -i -iutils/count-deps/. -iutils/count-deps/dist-install/build -Iutils/count-deps/dist-install/build -iutils/count-deps/dist-install/build/count-deps/autogen -Iutils/count-deps/dist-install/build/count-deps/autogen -optP-include -optPutils/count-deps/dist-install/build/count-deps/autogen/cabal_macros.h -package-id base-4.16.0.0 -package-id containers-0.6.4.1 -package-id ghc-9.3 -Wall -XHaskell2010 -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -outputdir utils/count-deps/dist-install/build -c utils/count-deps/./Main.hs -o utils/count-deps/dist-install/build/Main.dyn_o
ghc-stage2: internal error: ghc-stage2: internal error: evacuate: strange closure type 918375evacuate: strange closure type 918375ghc-stage2: internal error:
(GHC version 9.3.20211025 for riscv64_unknown_linux)
(GHC version 9.3.20211025 for riscv64_unknown_linux)
evacuate: strange closure type 918375 Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
(GHC version 9.3.20211025 for riscv64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [utils/count-deps/ghc.mk:18: utils/count-deps/dist-install/build/Main.dyn_o] Aborted (core dumped)
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [utils/check-exact/ghc.mk:18: utils/check-exact/dist-install/build/Types.dyn_o] Aborted (core dumped)
make[1]: *** [utils/check-ppr/ghc.mk:18: utils/check-ppr/dist-install/build/Main.dyn_o] Aborted (core dumped)
make: *** [Makefile:128: all] Error 2
```
sorry for mixed messages from several concurrenlty run ghc-stage2.
## Expected behavior
Build passes and ghc-stage2 is working.
## Environment
* GHC version used: GHC 8.10.7
Optional:
* Operating System: OpenSuSE Thumbleweed
* System Architecture: RISC-V649.4.1Ben GamariMatthew PickeringkgardasBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/20560"Impossible happened" panic on GHC 9.0.12022-02-24T12:08:05ZNikita Volkov"Impossible happened" panic on GHC 9.0.1## Summary
After adding Inline pragmas in a dependency I get the following compiler error:
```
[12 of 25] Compiling StructureKit.TouchTrackingHashMap
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.1:
applyTypeToArgs
Exp...## Summary
After adding Inline pragmas in a dependency I get the following compiler error:
```
[12 of 25] Compiling StructureKit.TouchTrackingHashMap
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.1:
applyTypeToArgs
Expression: $fAltList4 @a_akQd (Nil @a_akQd) ww2_akQh
Type: forall {a} {b}.
List (b -> a) -> List (b -> a) -> List (b -> a)
Args: [TYPE: a_akQd, Nil @a_akQd, ww2_akQh]
Args': [Nil @a_akQd, ww2_akQh]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Core/Utils.hs:276:17 in ghc:GHC.Core.Utils
```
## Steps to reproduce
1. Check out https://github.com/nikita-volkov/structure-kit/tree/ghc-bug
2. Run `stack build`
## Environment
* GHC version used:
9.0.1
Optional:
* Operating System: macOS 11.2.3
* System Architecture: IntelZubinZubin