GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2021-01-29T11:22:14Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/8657-fregs-graph still has a limit on spill slots2021-01-29T11:22:14ZSimon Marlow-fregs-graph still has a limit on spill slotsThe limit on spill slots was removed for the linear register allocator in 7.8, but not for `-fregs-graph`.
SHA-1 fails to compile with `-fregs-graph` in 7.8.
Related: #7679 (`-fregs-graph` generates poor code with the new codegen).
<d...The limit on spill slots was removed for the linear register allocator in 7.8, but not for `-fregs-graph`.
SHA-1 fails to compile with `-fregs-graph` in 7.8.
Related: #7679 (`-fregs-graph` generates poor code with the new codegen).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 7.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (NCG) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | simonmar |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"-fregs-graph still has a limit on spill slots","status":"New","operating_system":"","component":"Compiler (NCG)","related":[],"milestone":"7.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["simonmar"],"type":"Bug","description":"The limit on spill slots was removed for the linear register allocator in 7.8, but not for `-fregs-graph`.\r\n\r\nSHA-1 fails to compile with `-fregs-graph` in 7.8.\r\n\r\nRelated: #7679 (`-fregs-graph` generates poor code with the new codegen).\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1archblobarchblobhttps://gitlab.haskell.org/ghc/ghc/-/issues/13531GHC fails with "Dynamic linker not initialised" when -j is on and trying to l...2020-09-28T07:11:38ZNiklas Hambüchenmail@nh2.meGHC fails with "Dynamic linker not initialised" when -j is on and trying to load nonexistent .so fileFor ghc 8.0.2 (on Linux, in nixpkgs `0c041520c3` for exact reproducibility), when TH is used in a `ghc --make -j1` invocation, and thus ghc does the whole
```
cc -fno-stack-protector -DTABLES_NEXT_TO_CODE '-std=c++14' -Wno-deprecated-de...For ghc 8.0.2 (on Linux, in nixpkgs `0c041520c3` for exact reproducibility), when TH is used in a `ghc --make -j1` invocation, and thus ghc does the whole
```
cc -fno-stack-protector -DTABLES_NEXT_TO_CODE '-std=c++14' -Wno-deprecated-declarations --print-file-name liblibglog.so
Loading object (dynamic) glog ... done
```
business, and the `.so` file in question does not exist, then usually GHC prints
```
<command line>: user specified .o/.so/.DLL could not be loaded (libglog.so: cannot open shared object file: No such file or directory)
```
However, I found that when parallel compilation is enabled, (e.g. `ghc -j4`), I can get this instead:
```
[ 23 of 130] Compiling Mymodule ( Mymodule.hs, dist/build/Mymodule.o )
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-linux):
Dynamic linker not initialised
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | --------------------- |
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #9868, #10355, #13137 |
| Blocking | |
| CC | Phyx-, angerman, nh2 |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC fails with \"Dynamic linker not initialised\" when -j is on and trying to load nonexistent .so file","status":"New","operating_system":"","component":"Compiler","related":[9868,10355,13137],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["Phyx-","angerman","nh2"],"type":"Bug","description":"For ghc 8.0.2 (on Linux, in nixpkgs `0c041520c3` for exact reproducibility), when TH is used in a `ghc --make -j1` invocation, and thus ghc does the whole\r\n\r\n{{{\r\ncc -fno-stack-protector -DTABLES_NEXT_TO_CODE '-std=c++14' -Wno-deprecated-declarations --print-file-name liblibglog.so\r\nLoading object (dynamic) glog ... done\r\n}}}\r\n\r\nbusiness, and the `.so` file in question does not exist, then usually GHC prints\r\n\r\n{{{\r\n <command line>: user specified .o/.so/.DLL could not be loaded (libglog.so: cannot open shared object file: No such file or directory)\r\n}}}\r\n\r\nHowever, I found that when parallel compilation is enabled, (e.g. `ghc -j4`), I can get this instead:\r\n\r\n{{{\r\n[ 23 of 130] Compiling Mymodule ( Mymodule.hs, dist/build/Mymodule.o )\r\n\r\n<no location info>: error:\r\n ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.2 for x86_64-unknown-linux):\r\n Dynamic linker not initialised\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/13786GHCi linker is dependent upon object file order2020-02-17T11:34:32ZppelletiGHCi linker is dependent upon object file orderUsing [this package](https://github.com/ppelleti/hs-mercury-api), I tried doing "stack repl" with GHC 8.0.2:
```
whiteandnerdy:hs-mercury-api ppelleti$ stack repl
The following GHC options are incompatible with GHCi and have not been pa...Using [this package](https://github.com/ppelleti/hs-mercury-api), I tried doing "stack repl" with GHC 8.0.2:
```
whiteandnerdy:hs-mercury-api ppelleti$ stack repl
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
* * * * * * * *
The main module to load is ambiguous. Candidates are:
1. Package `mercury-api' component exe:tmr-firmware with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-firmware.hs
2. Package `mercury-api' component exe:tmr-gpio with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-gpio.hs
3. Package `mercury-api' component exe:tmr-lock with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-lock.hs
4. Package `mercury-api' component exe:tmr-params with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-params.hs
5. Package `mercury-api' component exe:tmr-read with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-read.hs
6. Package `mercury-api' component exe:tmr-write with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-write.hs
You can specify which one to pick by:
* Specifying targets to stack ghci e.g. stack ghci mercury-api:exe:tmr-firmware
* Specifying what the main is e.g. stack ghci --main-is mercury-api:exe:tmr-firmware
* Choosing from the candidate above [1..6]
* * * * * * * *
Specify main module to use (press enter to load none): 4
Loading main module from cadidate 4, --main-is /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-params.hs
Configuring GHCi with the following packages: mercury-api
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-apple-darwin):
Loading temp shared object failed: dlopen(/var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib, 5): Symbol not found: _TMR_SR_cmdStopReading
Referenced from: /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib
Expected in: flat namespace
in /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This bug appears to have been around a while, because it also happens with GHC 7.8.3:
```
whiteandnerdy:hs-mercury-api ppelleti$ cabal repl
Preprocessing library mercury-api-0.1.0.0...
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package binary-0.7.1.0 ... linking ... done.
Loading package text-1.2.2.1 ... linking ... done.
Loading package hashable-1.2.6.0 ... linking ... done.
Loading package unordered-containers-0.2.8.0 ... linking ... done.
Loading package clock-0.7.2 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package ansi-terminal-0.6.2.3 ... linking ... done.
Loading object (static) dist/build/cbits/api/tmr_strerror.o ... done
Loading object (static) dist/build/cbits/api/tmr_param.o ... done
Loading object (static) dist/build/cbits/api/hex_bytes.o ... done
Loading object (static) dist/build/cbits/api/tm_reader.o ... ghc: panic! (the 'impossible' happened)
(GHC version 7.8.3 for x86_64-apple-darwin):
Loading temp shared object failed: dlopen(/var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib, 9): Symbol not found: _TMR_SR_SerialTransportNativeInit
Referenced from: /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib
Expected in: flat namespace
in /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
I'm using Mac OS X 10.9.5:
```
whiteandnerdy:hs-mercury-api ppelleti$ uname -a
Darwin whiteandnerdy.lan 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | MacOS X |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"GHC panic on Mac OS X with \"cabal repl\" / \"stack repl\" on GHC 8.0.2 and 7.8.3","status":"New","operating_system":"MacOS X","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"Using [https://github.com/ppelleti/hs-mercury-api this package], I tried doing \"stack repl\" with GHC 8.0.2:\r\n\r\n{{{\r\nwhiteandnerdy:hs-mercury-api ppelleti$ stack repl\r\nThe following GHC options are incompatible with GHCi and have not been passed to it: -threaded\r\n\r\n* * * * * * * *\r\nThe main module to load is ambiguous. Candidates are: \r\n1. Package `mercury-api' component exe:tmr-firmware with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-firmware.hs\r\n2. Package `mercury-api' component exe:tmr-gpio with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-gpio.hs\r\n3. Package `mercury-api' component exe:tmr-lock with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-lock.hs\r\n4. Package `mercury-api' component exe:tmr-params with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-params.hs\r\n5. Package `mercury-api' component exe:tmr-read with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-read.hs\r\n6. Package `mercury-api' component exe:tmr-write with main-is file: /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-write.hs\r\nYou can specify which one to pick by: \r\n * Specifying targets to stack ghci e.g. stack ghci mercury-api:exe:tmr-firmware\r\n * Specifying what the main is e.g. stack ghci --main-is mercury-api:exe:tmr-firmware\r\n * Choosing from the candidate above [1..6]\r\n* * * * * * * *\r\n\r\nSpecify main module to use (press enter to load none): 4\r\nLoading main module from cadidate 4, --main-is /Users/ppelleti/programming/haskell/hs-mercury-api/examples/tmr-params.hs\r\n\r\nConfiguring GHCi with the following packages: mercury-api\r\nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.2 for x86_64-apple-darwin):\r\n\tLoading temp shared object failed: dlopen(/var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib, 5): Symbol not found: _TMR_SR_cmdStopReading\r\n Referenced from: /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib\r\n Expected in: flat namespace\r\n in /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91859_0/libghc_5.dylib\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThis bug appears to have been around a while, because it also happens with GHC 7.8.3:\r\n\r\n{{{\r\nwhiteandnerdy:hs-mercury-api ppelleti$ cabal repl\r\nPreprocessing library mercury-api-0.1.0.0...\r\nGHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer-gmp ... linking ... done.\r\nLoading package base ... linking ... done.\r\nLoading package array-0.5.0.0 ... linking ... done.\r\nLoading package deepseq-1.3.0.2 ... linking ... done.\r\nLoading package bytestring-0.10.4.0 ... linking ... done.\r\nLoading package containers-0.5.5.1 ... linking ... done.\r\nLoading package binary-0.7.1.0 ... linking ... done.\r\nLoading package text-1.2.2.1 ... linking ... done.\r\nLoading package hashable-1.2.6.0 ... linking ... done.\r\nLoading package unordered-containers-0.2.8.0 ... linking ... done.\r\nLoading package clock-0.7.2 ... linking ... done.\r\nLoading package old-locale-1.0.0.6 ... linking ... done.\r\nLoading package time-1.4.2 ... linking ... done.\r\nLoading package unix-2.7.0.1 ... linking ... done.\r\nLoading package ansi-terminal-0.6.2.3 ... linking ... done.\r\nLoading object (static) dist/build/cbits/api/tmr_strerror.o ... done\r\nLoading object (static) dist/build/cbits/api/tmr_param.o ... done\r\nLoading object (static) dist/build/cbits/api/hex_bytes.o ... done\r\nLoading object (static) dist/build/cbits/api/tm_reader.o ... ghc: panic! (the 'impossible' happened)\r\n (GHC version 7.8.3 for x86_64-apple-darwin):\r\n\tLoading temp shared object failed: dlopen(/var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib, 9): Symbol not found: _TMR_SR_SerialTransportNativeInit\r\n Referenced from: /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib\r\n Expected in: flat namespace\r\n in /var/folders/d1/v9ptqpx12mdcxj77509440rc0000gn/T/ghc91576_0/ghc91576_4.dylib\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nI'm using Mac OS X 10.9.5:\r\n\r\n{{{\r\nwhiteandnerdy:hs-mercury-api ppelleti$ uname -a\r\nDarwin whiteandnerdy.lan 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/14627qAddTopDecls: can't convert top-level declarations2020-10-08T17:37:16ZtianxiaoguqAddTopDecls: can't convert top-level declarationsThe following program crashes 8.2.2 and HEAD (8.5.20171228).
```hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax (addTopDecls)
$(do
ds <- [d| f = Bool
|]
addTopDecls ds
[d| ...The following program crashes 8.2.2 and HEAD (8.5.20171228).
```hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax (addTopDecls)
$(do
ds <- [d| f = Bool
|]
addTopDecls ds
[d| g = cab
|])
```
Output:
```
Exception when trying to run compile-time code:
ghc: panic! (the 'impossible' happened)
(GHC version 8.5.20171228 for x86_64-unknown-linux):
qAddTopDecls: can't convert top-level declarations
Illegal variable name: ‘Bool’
When splicing a TH declaration: f_0 = Bool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcSplice.hs:886:27 in ghc:TcSplice
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"qAddTopDecls: can't convert top-level declarations","status":"New","operating_system":"Linux","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"The following program crashes 8.2.2 and HEAD (8.5.20171228).\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\nimport Language.Haskell.TH.Syntax (addTopDecls)\r\n$(do\r\n ds <- [d| f = Bool\r\n |]\r\n addTopDecls ds\r\n [d| g = cab\r\n |])\r\n}}}\r\nOutput:\r\n{{{\r\n Exception when trying to run compile-time code:\r\n ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20171228 for x86_64-unknown-linux):\r\n\tqAddTopDecls: can't convert top-level declarations\r\n\r\nIllegal variable name: ‘Bool’\r\nWhen splicing a TH declaration: f_0 = Bool\r\nCall stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcSplice.hs:886:27 in ghc:TcSplice\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Michael SloanMichael Sloanhttps://gitlab.haskell.org/ghc/ghc/-/issues/15076Typed hole with higher-rank kind causes GHC to panic (No skolem info)2019-07-07T18:14:23ZRyan ScottTyped hole with higher-rank kind causes GHC to panic (No skolem info)Spun out from #14040\#[ticket:15076\#comment:152359](https://gitlab.haskell.org//ghc/ghc/issues/15076#note_152359), which was different enough from the original program in #14040 to warrant its own ticket. The following program panics on...Spun out from #14040\#[ticket:15076\#comment:152359](https://gitlab.haskell.org//ghc/ghc/issues/15076#note_152359), which was different enough from the original program in #14040 to warrant its own ticket. The following program panics on every version of GHC from 8.0.2 onward:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
import Data.Proxy
foo :: forall (a :: Type)
(f :: forall (x :: a). Proxy x -> Type).
Proxy f -> ()
foo (_ :: _) = ()
```
```
$ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:11: error:ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180420 for x86_64-unknown-linux):
No skolem info:
[a_aZo[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:3224:5 in ghc:TcErrors
```8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15325GHCi panic in getIdFromTrivialExpr with -fdefer-type-errors2020-11-18T11:28:48ZdramforeverGHCi panic in getIdFromTrivialExpr with -fdefer-type-errors## Steps to reproduce:
Put this in `bug.hs`: (It's a very failed attempt to make a polymorphic list maker function.)
```hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module ...## Steps to reproduce:
Put this in `bug.hs`: (It's a very failed attempt to make a polymorphic list maker function.)
```hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module PolyvariadicFunctions where
class PolyList e a where
polyList :: ([e] -> [e]) -> a
-- instance PolyList e [e] where
-- polyList dl = dl []
instance (e ~ e2, PolyList e a) => PolyList e (e2 -> a) where
polyList dl x = polyList ((x :) . dl)
plh :: [Integer]
plh = polyList 1 2 3 4 5
```
Load it in GHCi with `-fdefer-type-errors` to get the following output. Note the 'panic' in the end, and also note that the last `>` line is a no-module-loaded GHCi prompt.
The question marks `?` seem to be encoding related and not relevant.
This panic not seem to occur with GHC the compiler. The rest of the error messages seem otherwise identical.
```
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Prelude> :set -fdefer-type-errors
Prelude> :l bug.hs
[1 of 1] Compiling PolyvariadicFunctions ( bug.hs, interpreted )
bug.hs:17:7: warning: [-Wdeferred-type-errors]
? No instance for (PolyList t0 [Integer])
arising from a use of ‘polyList’
? In the expression: polyList 1 2 3 4 5
In an equation for ‘plh’: plh = polyList 1 2 3 4 5
|
17 | plh = polyList 1 2 3 4 5
| ^^^^^^^^^^^^^^^^^^
bug.hs:17:16: warning: [-Wdeferred-type-errors]
? No instance for (Num ([t0] -> [t0])) arising from the literal ‘1’
(maybe you haven't applied a function to enough arguments?)
? In the first argument of ‘polyList’, namely ‘1’
In the expression: polyList 1 2 3 4 5
In an equation for ‘plh’: plh = polyList 1 2 3 4 5
|
17 | plh = polyList 1 2 3 4 5
| ^
bug.hs:17:18: warning: [-Wdeferred-type-errors]
? Ambiguous type variable ‘t0’ arising from the literal ‘2’
prevents the constraint ‘(Num t0)’ from being solved.
Probable fix: use a type annotation to specify what ‘t0’ should be.
These potential instances exist:
instance Num Integer -- Defined in ‘GHC.Num’
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
...plus two others
(use -fprint-potential-instances to see them all)
? In the second argument of ‘polyList’, namely ‘2’
In the expression: polyList 1 2 3 4 5
In an equation for ‘plh’: plh = polyList 1 2 3 4 5
|
17 | plh = polyList 1 2 3 4 5
| ^
ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-mingw32):
getIdFromTrivialExpr
case $dNum_a1Be of wild_00 { }
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler\\coreSyn\\CoreUtils.hs:883:18 in ghc:CoreUtils
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
>
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.3 |
| 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":"Panic in getIdFromTrivialExpr with -fdefer-type-errors","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"== Steps to reproduce:\r\n\r\nPut this in `bug.hs`: (It's a very failed attempt to make a polymorphic list maker function.)\r\n\r\n{{{#!hs\r\n{-# LANGUAGE FlexibleInstances #-}\r\n{-# LANGUAGE MultiParamTypeClasses #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\nmodule PolyvariadicFunctions where\r\n\r\nclass PolyList e a where\r\n polyList :: ([e] -> [e]) -> a\r\n\r\n-- instance PolyList e [e] where\r\n-- polyList dl = dl []\r\n\r\ninstance (e ~ e2, PolyList e a) => PolyList e (e2 -> a) where\r\n polyList dl x = polyList ((x :) . dl)\r\n\r\nplh :: [Integer]\r\nplh = polyList 1 2 3 4 5\r\n}}}\r\n\r\nLoad it in GHCi with `-fdefer-type-errors` to get the following output. Note the 'panic' in the end, and also note that the last `>` line is a no-module-loaded GHCi prompt.\r\n\r\nThe question marks `?` seem to be encoding related and not relevant.\r\n\r\nThis panic not seem to occur with GHC the compiler. The rest of the error messages seem otherwise identical.\r\n\r\n{{{\r\nGHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help\r\nPrelude> :set -fdefer-type-errors\r\nPrelude> :l bug.hs\r\n[1 of 1] Compiling PolyvariadicFunctions ( bug.hs, interpreted )\r\n\r\nbug.hs:17:7: warning: [-Wdeferred-type-errors]\r\n ? No instance for (PolyList t0 [Integer])\r\n arising from a use of ‘polyList’\r\n ? In the expression: polyList 1 2 3 4 5\r\n In an equation for ‘plh’: plh = polyList 1 2 3 4 5\r\n |\r\n17 | plh = polyList 1 2 3 4 5\r\n | ^^^^^^^^^^^^^^^^^^\r\n\r\nbug.hs:17:16: warning: [-Wdeferred-type-errors]\r\n ? No instance for (Num ([t0] -> [t0])) arising from the literal ‘1’\r\n (maybe you haven't applied a function to enough arguments?)\r\n ? In the first argument of ‘polyList’, namely ‘1’\r\n In the expression: polyList 1 2 3 4 5\r\n In an equation for ‘plh’: plh = polyList 1 2 3 4 5\r\n |\r\n17 | plh = polyList 1 2 3 4 5\r\n | ^\r\n\r\nbug.hs:17:18: warning: [-Wdeferred-type-errors]\r\n ? Ambiguous type variable ‘t0’ arising from the literal ‘2’\r\n prevents the constraint ‘(Num t0)’ from being solved.\r\n Probable fix: use a type annotation to specify what ‘t0’ should be.\r\n These potential instances exist:\r\n instance Num Integer -- Defined in ‘GHC.Num’\r\n instance Num Double -- Defined in ‘GHC.Float’\r\n instance Num Float -- Defined in ‘GHC.Float’\r\n ...plus two others\r\n (use -fprint-potential-instances to see them all)\r\n ? In the second argument of ‘polyList’, namely ‘2’\r\n In the expression: polyList 1 2 3 4 5\r\n In an equation for ‘plh’: plh = polyList 1 2 3 4 5\r\n |\r\n17 | plh = polyList 1 2 3 4 5\r\n | ^\r\nghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-mingw32):\r\n getIdFromTrivialExpr\r\n case $dNum_a1Be of wild_00 { }\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\coreSyn\\\\CoreUtils.hs:883:18 in ghc:CoreUtils\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n>\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15368Type families, holes and -fdefer-type-errors may cause 'opt_univ fell into a ...2019-07-07T18:12:57ZdramforeverType families, holes and -fdefer-type-errors may cause 'opt_univ fell into a hole' panicThis program, when compiled like `ghc -fdefer-type-errors -c panic.hs`:
```hs
{-# LANGUAGE TypeFamilies #-}
module MorePanic where
transitive :: (a, b) -> (b, c) -> (a, c)
transitive = undefined
trigger :: a -> b -> (F a b, F b a)
tr...This program, when compiled like `ghc -fdefer-type-errors -c panic.hs`:
```hs
{-# LANGUAGE TypeFamilies #-}
module MorePanic where
transitive :: (a, b) -> (b, c) -> (a, c)
transitive = undefined
trigger :: a -> b -> (F a b, F b a)
trigger _ _ = _ `transitive` trigger _ _
type family F (n :: *) (m :: *) :: *
```
Gives this panic after several error messages:
```
ghc.EXE: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-mingw32):
opt_univ fell into a hole
{co_a7Sj}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler\\types\\OptCoercion.hs:242:5 in ghc:OptCoercion
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This bug also affects GHCi. Attached is full output
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.3 |
| 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":"Type families, holes and -fdefer-type-errors may cause 'opt_univ fell into a hole' panic","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"\r\nThis program, when compiled like `ghc -fdefer-type-errors -c panic.hs`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TypeFamilies #-}\r\n\r\nmodule MorePanic where\r\n\r\ntransitive :: (a, b) -> (b, c) -> (a, c)\r\ntransitive = undefined\r\n\r\ntrigger :: a -> b -> (F a b, F b a)\r\ntrigger _ _ = _ `transitive` trigger _ _\r\n\r\ntype family F (n :: *) (m :: *) :: *\r\n}}}\r\n\r\nGives this panic after several error messages:\r\n\r\n{{{\r\nghc.EXE: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-mingw32):\r\n\topt_univ fell into a hole\r\n {co_a7Sj}\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\types\\\\OptCoercion.hs:242:5 in ghc:OptCoercion\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThis bug also affects GHCi. Attached is full output","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15517-O0 and pattern synonyms triggers panic in trimJoinCont2019-07-07T18:04:21ZSimon Jakobi-O0 and pattern synonyms triggers panic in trimJoinContRunning haddock on the [\`generics-mrsop\`](https://github.com/VictorCMiraldo/generics-mrsop) package results in
```
haddock: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
completeCall
fail_av9P
Se...Running haddock on the [\`generics-mrsop\`](https://github.com/VictorCMiraldo/generics-mrsop) package results in
```
haddock: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
completeCall
fail_av9P
Select nodup wild_00
Stop[BoringCtxt] Rep Singl (El FamRoseInt) (Lkup ix CodesRoseInt)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/simplCore/Simplify.hs:1533:9 in ghc:Simplify
```
The same problem affects 8.6.1 and HEAD, but not 8.2.2.
The panic seems to stem from [this catch-all in \`trimJoinCont\`](https://github.com/ghc/ghc/blob/64c71ce956af3af593a46ef0d615c7f6fe6ecece/compiler/simplCore/Simplify.hs#L1613).8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15549Core Lint error with EmptyCase2019-07-07T18:04:11ZRyan ScottCore Lint error with EmptyCaseThe following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
...The following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind
import Data.Void
data family Sing (a :: k)
data V1 :: Type -> Type
data instance Sing (z :: V1 p)
class Generic a where
type Rep a :: Type -> Type
to :: Rep a x -> a
class PGeneric a where
type To (z :: Rep a x) :: a
class SGeneric a where
sTo :: forall x (r :: Rep a x). Sing r -> Sing (To r :: a)
-----
instance Generic Void where
type Rep Void = V1
to x = case x of {}
type family EmptyCase (a :: j) :: k where
instance PGeneric Void where
type To x = EmptyCase x
instance SGeneric Void where
sTo x = case x of
```
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs -dcore-lint -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’
Function kind = forall k. k -> *
Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p -> *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p -> *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p -> V1 p -> *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p -> V1 p -> *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
*** Offending Program ***
<elided>
$csTo_a12n :: forall x (r :: Rep Void x). Sing r -> Sing (To r)
[LclId,
Arity=1,
Str=<L,U>x,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
$csTo_a12n
= \ (@ x_a12p)
(@ (r_a12q :: Rep Void x_a12p))
(x_aZ8 :: Sing r_a12q) ->
case x_aZ8
`cast` ((Sing
(D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]
<x_a12p>_N <r_a12q>_N
:: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))
of nt_s13T {
}
```
GHC 8.0.2 does not appear to suffer from this Core Lint error.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Core Lint error with empty closed type family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.2.2 and later:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE EmptyCase #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ndata family Sing (a :: k)\r\n\r\ndata V1 :: Type -> Type\r\ndata instance Sing (z :: V1 p)\r\n\r\nclass Generic a where\r\n type Rep a :: Type -> Type\r\n to :: Rep a x -> a\r\n\r\nclass PGeneric a where\r\n type To (z :: Rep a x) :: a\r\n\r\nclass SGeneric a where\r\n sTo :: forall x (r :: Rep a x). Sing r -> Sing (To r :: a)\r\n\r\n-----\r\n\r\ninstance Generic Void where\r\n type Rep Void = V1\r\n to x = case x of {}\r\n\r\ntype family EmptyCase (a :: j) :: k where\r\n\r\ninstance PGeneric Void where\r\n type To x = EmptyCase x\r\n\r\ninstance SGeneric Void where\r\n sTo x = case x of\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs -dcore-lint -fforce-recomp \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’\r\n Function kind = forall k. k -> *\r\n Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p -> *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p -> *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p -> V1 p -> *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p -> V1 p -> *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csTo_a12n :: forall x (r :: Rep Void x). Sing r -> Sing (To r)\r\n[LclId,\r\n Arity=1,\r\n Str=<L,U>x,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\n$csTo_a12n\r\n = \\ (@ x_a12p)\r\n (@ (r_a12q :: Rep Void x_a12p))\r\n (x_aZ8 :: Sing r_a12q) ->\r\n case x_aZ8\r\n `cast` ((Sing\r\n (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]\r\n <x_a12p>_N <r_a12q>_N\r\n :: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))\r\n of nt_s13T {\r\n }\r\n}}}\r\n\r\nGHC 8.0.2 does not appear to suffer from this Core Lint error.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15552Infinite loop/panic with an existential type.2019-07-07T18:04:11ZhowtonotwinInfinite loop/panic with an existential type.The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.
To reproduce:
1. Make `T.hs`
```hs
{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOp...The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.
To reproduce:
1. Make `T.hs`
```hs
{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOperators #-}
module T where
import Data.Kind
data Elem :: k -> [k] -> Type where
Here :: Elem x (x : xs)
There :: Elem x xs -> Elem x (y : xs)
data EntryOfVal (v :: Type) (kvs :: [Type]) = forall (k :: Type). EntryOfVal (Elem (k, v) kvs)
```
1. Compile it with `ghc T.hs -ddump-tc-trace`
```
# etc.
checkExpectedKind
*
TYPE t_aXd[tau:1]
<*>_N
kcLHsQTyVars: not-cusk
EntryOfVal
[]
[(k_aW0 :: Type)]
[]
[k_aW0[sk:1]]
*ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-apple-darwin):
kcConDecl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
1. Append the following to `T.hs` (not minimized, sorry)
```hs
type family EntryOfValKey (eov :: EntryOfVal v kvs) :: Type where
EntryOfValKey ('EntryOfVal (_ :: Elem (k, v) kvs)) = k
type family GetEntryOfVal (eov :: EntryOfVal v kvs) :: Elem (EntryOfValKey eov, v) kvs where
GetEntryOfVal ('EntryOfVal e) = e
type family FirstEntryOfVal (v :: Type) (kvs :: [Type]) :: EntryOfVal v kvs where
FirstEntryOfVal v ((k, v) : _) = 'EntryOfVal Here
FirstEntryOfVal v (_ : kvs) = 'EntryOfVal (There (GetEntryOfVal (FirstEntryOfVal v kvs)))
```
1. Compile with a plain `ghc T.hs`
1. Wait until bored, then knock the compiler out of its infinite loop by killing it.
1. Compile again with `ghc T.hs -ddump-tc-trace`
```
# etc.
checkExpectedKind
*
TYPE t_aYg[tau:1]
<*>_N
kcLHsQTyVars: not-cuskghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-apple-darwin):
kcConDecl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Found while trying to answer [this SO question](https://stackoverflow.com/q/51944931/5684257).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.3 |
| 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":"Infinite loop/panic with an existential type.","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.\r\n\r\nTo reproduce:\r\n\r\n1. Make `T.hs`\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOperators #-}\r\nmodule T where\r\n\r\nimport Data.Kind\r\n\r\ndata Elem :: k -> [k] -> Type where\r\n Here :: Elem x (x : xs)\r\n There :: Elem x xs -> Elem x (y : xs)\r\n\r\ndata EntryOfVal (v :: Type) (kvs :: [Type]) = forall (k :: Type). EntryOfVal (Elem (k, v) kvs)\r\n}}}\r\n\r\n2. Compile it with `ghc T.hs -ddump-tc-trace`\r\n{{{\r\n# etc.\r\ncheckExpectedKind\r\n *\r\n TYPE t_aXd[tau:1]\r\n <*>_N\r\nkcLHsQTyVars: not-cusk\r\n EntryOfVal\r\n []\r\n [(k_aW0 :: Type)]\r\n []\r\n [k_aW0[sk:1]]\r\n *ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-apple-darwin):\r\n\tkcConDecl\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\n3. Append the following to `T.hs` (not minimized, sorry)\r\n{{{#!hs\r\ntype family EntryOfValKey (eov :: EntryOfVal v kvs) :: Type where\r\n EntryOfValKey ('EntryOfVal (_ :: Elem (k, v) kvs)) = k\r\ntype family GetEntryOfVal (eov :: EntryOfVal v kvs) :: Elem (EntryOfValKey eov, v) kvs where\r\n GetEntryOfVal ('EntryOfVal e) = e\r\n\r\ntype family FirstEntryOfVal (v :: Type) (kvs :: [Type]) :: EntryOfVal v kvs where\r\n FirstEntryOfVal v ((k, v) : _) = 'EntryOfVal Here\r\n FirstEntryOfVal v (_ : kvs) = 'EntryOfVal (There (GetEntryOfVal (FirstEntryOfVal v kvs)))\r\n}}}\r\n\r\n4. Compile with a plain `ghc T.hs`\r\n 1. Wait until bored, then knock the compiler out of its infinite loop by killing it.\r\n5. Compile again with `ghc T.hs -ddump-tc-trace`\r\n{{{\r\n# etc.\r\ncheckExpectedKind\r\n *\r\n TYPE t_aYg[tau:1]\r\n <*>_N\r\nkcLHsQTyVars: not-cuskghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-apple-darwin):\r\n\tkcConDecl\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nFound while trying to answer [https://stackoverflow.com/q/51944931/5684257 this SO question].","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15629"No skolem info" panic (GHC 8.6 only)2019-07-07T18:03:40ZRyan Scott"No skolem info" panic (GHC 8.6 only)The following program:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug wher...The following program:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind
import Data.Proxy
import GHC.Generics
data TyFun :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k -> Type
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }
singFun1 :: forall f. (forall t. Sing t -> Sing (Apply f t)) -> Sing f
singFun1 f = SLambda f
data From1Sym0 :: forall k (f :: k -> Type) (a :: k). f a ~> Rep1 f a
data To1Sym0 :: forall k (f :: k -> Type) (a :: k). Rep1 f a ~> f a
type family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where
(f :. g) x = Apply f (Apply g x)
data (.@#@$$$) :: forall b c a. (b ~> c) -> (a ~> b) -> (a ~> c)
type instance Apply (f .@#@$$$ g) x = (f :. g) x
(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f -> Sing g -> Sing x -> Sing ((f :. g) x)
(sf %. sg) sx = applySing sf (applySing sg sx)
(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f -> Sing g -> Sing (f .@#@$$$ g)
sf %.$$$ sg = singFun1 (sf %. sg)
f :: forall (m :: Type -> Type) x. Proxy (m x) -> ()
f _ = ()
where
sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)
sFrom1Fun = undefined
sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)
sTo1Fun = undefined
sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
```
Panics on GHC 8.6:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab1’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)
|
50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180823 for x86_64-unknown-linux):
No skolem info:
[ab_a1UW[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
But merely errors on GHC 8.4.3:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab2’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)
|
50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:
• Couldn't match type ‘ab1’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5-112
Expected type: Sing From1Sym0
Actual type: Sing From1Sym0
• In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)
|
51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
| ^^^^^^^^^
Bug.hs:51:36: error:
• Couldn't match type ‘ab’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5-112
Expected type: Sing To1Sym0
Actual type: Sing To1Sym0
• In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)
|
51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
| ^^^^^^^
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.6.1-beta1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"\"No skolem info\" panic (GHC 8.6 only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1-beta1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\nimport GHC.Generics\r\n\r\ndata TyFun :: Type -> Type -> Type\r\ntype a ~> b = TyFun a b -> Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k -> Type\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }\r\nsingFun1 :: forall f. (forall t. Sing t -> Sing (Apply f t)) -> Sing f\r\nsingFun1 f = SLambda f\r\n\r\ndata From1Sym0 :: forall k (f :: k -> Type) (a :: k). f a ~> Rep1 f a\r\ndata To1Sym0 :: forall k (f :: k -> Type) (a :: k). Rep1 f a ~> f a\r\n\r\ntype family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where\r\n (f :. g) x = Apply f (Apply g x)\r\n\r\ndata (.@#@$$$) :: forall b c a. (b ~> c) -> (a ~> b) -> (a ~> c)\r\ntype instance Apply (f .@#@$$$ g) x = (f :. g) x\r\n\r\n(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f -> Sing g -> Sing x -> Sing ((f :. g) x)\r\n(sf %. sg) sx = applySing sf (applySing sg sx)\r\n\r\n(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f -> Sing g -> Sing (f .@#@$$$ g)\r\nsf %.$$$ sg = singFun1 (sf %. sg)\r\n\r\nf :: forall (m :: Type -> Type) x. Proxy (m x) -> ()\r\nf _ = ()\r\n where\r\n sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)\r\n sFrom1Fun = undefined\r\n\r\n sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)\r\n sTo1Fun = undefined\r\n\r\n sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n}}}\r\n\r\nPanics on GHC 8.6:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab1’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n |\r\n50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180823 for x86_64-unknown-linux):\r\n No skolem info:\r\n [ab_a1UW[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nBut merely errors on GHC 8.4.3:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab2’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n |\r\n50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:\r\n • Couldn't match type ‘ab1’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5-112\r\n Expected type: Sing From1Sym0\r\n Actual type: Sing From1Sym0\r\n • In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n |\r\n51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n | ^^^^^^^^^\r\n\r\nBug.hs:51:36: error:\r\n • Couldn't match type ‘ab’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5-112\r\n Expected type: Sing To1Sym0\r\n Actual type: Sing To1Sym0\r\n • In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n |\r\n51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n | ^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15648Core Lint error with source-level unboxed equality2019-07-07T18:03:36ZRyan ScottCore Lint error with source-level unboxed equalityI thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.
The trick is to grab `(...I thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.
The trick is to grab `(~#)` using Template Haskell:
```hs
module Foo where
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
ueqT :: Q Type
ueqT = conT $ mkNameG_tc "ghc-prim" "GHC.Prim" "~#"
```
Once this is done, you can plop unboxed equality wherever you want into the source language. Here is a particularly mischievous example:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind (Type)
import Data.Type.Equality (type (~~))
import Foo (ueqT)
data LegitEquality :: Type -> Type -> Type where
Legit :: LegitEquality a a
data JankyEquality :: Type -> Type -> Type where
Jank :: $ueqT a b -> JankyEquality a b
unJank :: JankyEquality a b -> $ueqT a b
unJank (Jank x) = x
legitToJank :: LegitEquality a b -> JankyEquality a b
legitToJank Legit = Jank
mkLegit :: a ~~ b => LegitEquality a b
mkLegit = Legit
ueqSym :: forall (a :: Type) (b :: Type).
$ueqT a b -> $ueqT b a
ueqSym = unJank $ legitToJank $ mkLegit @b @a
```
If you compile this with optimizations, then GHC's inner demons are unleashed, which brings utter chaos when `-dcore-lint` is enabled:
```
$ /opt/ghc/8.6.1/bin/ghc -O2 -fforce-recomp Bug.hs -dcore-lint
[1 of 2] Compiling Foo ( Foo.hs, Foo.o )
[2 of 2] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
[in body of lambda with binder co_a5RY :: a_a5RV ~# b_a5RW]
x_a5OX :: b_a5RW ~# a_a5RV
[LclId] is out of scope
*** Offending Program ***
<elided>
ueqSym :: forall a b. (a ~# b) => b ~# a
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
ueqSym
= \ (@ a_a5RV) (@ b_a5RW) (co_a5RY :: a_a5RV ~# b_a5RW) -> x_a5OX
```
-----
Obviously, this ticket is a little tongue-in-cheek, since I'm probably inviting disaster upon myself by deliberately digging around in `ghc-prim` for `(~#)`. But this does raise the question: should we allow users to do this? I used to think that there was no harm in leaving `(~#)` lying at the bottom of the catacombs that is `ghc-prim`, but this example shows that perhaps `(~#)` should be locked away for good.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.3 |
| 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":"Core Lint error with source-level unboxed equality","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.\r\n\r\nThe trick is to grab `(~#)` using Template Haskell:\r\n\r\n{{{#!hs\r\nmodule Foo where\r\n\r\nimport Language.Haskell.TH.Lib\r\nimport Language.Haskell.TH.Syntax\r\n\r\nueqT :: Q Type\r\nueqT = conT $ mkNameG_tc \"ghc-prim\" \"GHC.Prim\" \"~#\"\r\n}}}\r\n\r\nOnce this is done, you can plop unboxed equality wherever you want into the source language. Here is a particularly mischievous example:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE KindSignatures #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\nimport Data.Type.Equality (type (~~))\r\nimport Foo (ueqT)\r\n\r\ndata LegitEquality :: Type -> Type -> Type where\r\n Legit :: LegitEquality a a\r\n\r\ndata JankyEquality :: Type -> Type -> Type where\r\n Jank :: $ueqT a b -> JankyEquality a b\r\n\r\nunJank :: JankyEquality a b -> $ueqT a b\r\nunJank (Jank x) = x\r\n\r\nlegitToJank :: LegitEquality a b -> JankyEquality a b\r\nlegitToJank Legit = Jank\r\n\r\nmkLegit :: a ~~ b => LegitEquality a b\r\nmkLegit = Legit\r\n\r\nueqSym :: forall (a :: Type) (b :: Type).\r\n $ueqT a b -> $ueqT b a\r\nueqSym = unJank $ legitToJank $ mkLegit @b @a\r\n}}}\r\n\r\nIf you compile this with optimizations, then GHC's inner demons are unleashed, which brings utter chaos when `-dcore-lint` is enabled:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc -O2 -fforce-recomp Bug.hs -dcore-lint \r\n[1 of 2] Compiling Foo ( Foo.hs, Foo.o )\r\n[2 of 2] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n [in body of lambda with binder co_a5RY :: a_a5RV ~# b_a5RW]\r\n x_a5OX :: b_a5RW ~# a_a5RV\r\n [LclId] is out of scope\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nueqSym :: forall a b. (a ~# b) => b ~# a\r\n[LclIdX,\r\n Arity=1,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\nueqSym\r\n = \\ (@ a_a5RV) (@ b_a5RW) (co_a5RY :: a_a5RV ~# b_a5RW) -> x_a5OX\r\n}}}\r\n\r\n-----\r\n\r\nObviously, this ticket is a little tongue-in-cheek, since I'm probably inviting disaster upon myself by deliberately digging around in `ghc-prim` for `(~#)`. But this does raise the question: should we allow users to do this? I used to think that there was no harm in leaving `(~#)` lying at the bottom of the catacombs that is `ghc-prim`, but this example shows that perhaps `(~#)` should be locked away for good.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15718Build panic on ghc-8.6.1 under FreeBSD when using -fllvm2022-07-11T05:56:05Zgwright@antiope.comBuild panic on ghc-8.6.1 under FreeBSD when using -fllvmThis looks like a straightforward oversight. I am building my pure haskell LU solver under FreeBSD. I use the -fllvm compiler option because I need extra numerical performance.
When I build, I get (this is the output from GitLab CI, whi...This looks like a straightforward oversight. I am building my pure haskell LU solver under FreeBSD. I use the -fllvm compiler option because I need extra numerical performance.
When I build, I get (this is the output from GitLab CI, which is in turn running 'stack build')
```
Running with gitlab-runner 11.2.0 (35e8515d)
on stacker.18clay.com a2111f63
Using Shell executor...
Running on stacker.18clay.com...
Fetching changes...
Removing .stack-work/
HEAD is now at f8fe3b4 Use llvm60 on FreeBSD.
From https://gitlab.18clay.com/software/luSolve
f8fe3b4..c993a26 streamlined -> origin/streamlined
Checking out c993a262 as streamlined...
Skipping Git submodules setup
$ stack build --pedantic
luSolve-0.5: configure (lib)
Configuring luSolve-0.5...
luSolve-0.5: build (lib)
Preprocessing library for luSolve-0.5..
Building library for luSolve-0.5..
[1 of 1] Compiling Numeric.LinearAlgebra.LUSolve ( src/Numeric/LinearAlgebra/LUSolve.hs, .stack-work/dist/x86_64-freebsd/Cabal-2.4.0.1/build/Numeric/LinearAlgebra/LUSolve.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64-portbld-freebsd):
Failed to lookup the datalayout for x86_64-unknown-freebsd; available targets: ["i386-unknown-windows","i686-unknown-windows","x86_64-unknown-windows","arm-unknown-linux-gnueabihf","armv6-unknown-linux-gnueabihf","armv6l-unknown-linux-gnueabihf","armv7-unknown-linux-gnueabihf","armv7a-unknown-linux-gnueabi","armv7l-unknown-linux-gnueabihf","aarch64-unknown-linux-gnu","aarch64-unknown-linux","i386-unknown-linux-gnu","i386-unknown-linux","x86_64-unknown-linux-gnu","x86_64-unknown-linux","armv7-unknown-linux-androideabi","aarch64-unknown-linux-android","powerpc64le-unknown-linux","amd64-portbld-freebsd","arm-unknown-nto-qnx-eabi","i386-apple-darwin","x86_64-apple-darwin","armv7-apple-ios","aarch64-apple-ios","i386-apple-ios","x86_64-apple-ios","aarch64-unknown-freebsd","armv6-unknown-freebsd-gnueabihf","armv7-unknown-freebsd-gnueabihf"]
CallStack (from HasCallStack):
error, called at compiler/llvmGen/LlvmCodeGen.hs:96:24 in ghc:LlvmCodeGen
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-- While building custom Setup.hs for package luSolve-0.5 using:
/home/gitlab-runner/.stack/setup-exe-cache/x86_64-freebsd/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.1 --builddir=.stack-work/dist/x86_64-freebsd/Cabal-2.4.0.1 build lib:luSolve --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
ERROR: Job failed: exit status 1
```
The bug seems simple. The compiler is looking for the datalayout for x86_64-unknown-freebsd; but what is available is amd64-portbld-freebsd. Is this just a simple naming error? The stack resolver was the cutting-edge nightly-2018-10-6; if it is a problem in their packaging rather than ghc itself I will file a report with them (though ghc did panic here, and as the breath ebbed from its ASTs and light faded from the code generator, it pleaded that a bug report be filed).
I've attached the .cabal file in case it helps.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.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":"Build panic on ghc-8.6.1 under FreeBSD when using -fllvm","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This looks like a straightforward oversight. I am building my pure haskell LU solver under FreeBSD. I use the -fllvm compiler option because I need extra numerical performance.\r\n\r\nWhen I build, I get (this is the output from GitLab CI, which is in turn running 'stack build')\r\n\r\n{{{\r\nRunning with gitlab-runner 11.2.0 (35e8515d)\r\n on stacker.18clay.com a2111f63\r\nUsing Shell executor...\r\nRunning on stacker.18clay.com...\r\nFetching changes...\r\nRemoving .stack-work/\r\nHEAD is now at f8fe3b4 Use llvm60 on FreeBSD.\r\nFrom https://gitlab.18clay.com/software/luSolve\r\n f8fe3b4..c993a26 streamlined -> origin/streamlined\r\nChecking out c993a262 as streamlined...\r\nSkipping Git submodules setup\r\n$ stack build --pedantic\r\nluSolve-0.5: configure (lib)\r\nConfiguring luSolve-0.5...\r\nluSolve-0.5: build (lib)\r\nPreprocessing library for luSolve-0.5..\r\nBuilding library for luSolve-0.5..\r\n[1 of 1] Compiling Numeric.LinearAlgebra.LUSolve ( src/Numeric/LinearAlgebra/LUSolve.hs, .stack-work/dist/x86_64-freebsd/Cabal-2.4.0.1/build/Numeric/LinearAlgebra/LUSolve.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.1 for x86_64-portbld-freebsd):\r\n\tFailed to lookup the datalayout for x86_64-unknown-freebsd; available targets: [\"i386-unknown-windows\",\"i686-unknown-windows\",\"x86_64-unknown-windows\",\"arm-unknown-linux-gnueabihf\",\"armv6-unknown-linux-gnueabihf\",\"armv6l-unknown-linux-gnueabihf\",\"armv7-unknown-linux-gnueabihf\",\"armv7a-unknown-linux-gnueabi\",\"armv7l-unknown-linux-gnueabihf\",\"aarch64-unknown-linux-gnu\",\"aarch64-unknown-linux\",\"i386-unknown-linux-gnu\",\"i386-unknown-linux\",\"x86_64-unknown-linux-gnu\",\"x86_64-unknown-linux\",\"armv7-unknown-linux-androideabi\",\"aarch64-unknown-linux-android\",\"powerpc64le-unknown-linux\",\"amd64-portbld-freebsd\",\"arm-unknown-nto-qnx-eabi\",\"i386-apple-darwin\",\"x86_64-apple-darwin\",\"armv7-apple-ios\",\"aarch64-apple-ios\",\"i386-apple-ios\",\"x86_64-apple-ios\",\"aarch64-unknown-freebsd\",\"armv6-unknown-freebsd-gnueabihf\",\"armv7-unknown-freebsd-gnueabihf\"]\r\nCallStack (from HasCallStack):\r\n error, called at compiler/llvmGen/LlvmCodeGen.hs:96:24 in ghc:LlvmCodeGen\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n\r\n-- While building custom Setup.hs for package luSolve-0.5 using:\r\n /home/gitlab-runner/.stack/setup-exe-cache/x86_64-freebsd/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.1 --builddir=.stack-work/dist/x86_64-freebsd/Cabal-2.4.0.1 build lib:luSolve --ghc-options \" -ddump-hi -ddump-to-file\"\r\n Process exited with code: ExitFailure 1\r\nERROR: Job failed: exit status 1\r\n}}}\r\n\r\nThe bug seems simple. The compiler is looking for the datalayout for x86_64-unknown-freebsd; but what is available is amd64-portbld-freebsd. Is this just a simple naming error? The stack resolver was the cutting-edge nightly-2018-10-6; if it is a problem in their packaging rather than ghc itself I will file a report with them (though ghc did panic here, and as the breath ebbed from its ASTs and light faded from the code generator, it pleaded that a bug report be filed).\r\n\r\nI've attached the .cabal file in case it helps.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15725Core Lint error: Trans coercion mis-match2019-07-07T18:03:14ZRyan ScottCore Lint error: Trans coercion mis-matchI discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:
```hs
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ...I discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:
```hs
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Functor.Identity (Identity(..))
import Data.Kind (Type)
import GHC.Exts (Any)
-----
-- The important bits
-----
type instance Meth (x :: Identity a) = GenericMeth x
instance SC Identity
-------------------------------------------------------------------------------
data family Sing :: forall k. k -> Type
data instance Sing :: forall a. Identity a -> Type where
SIdentity :: Sing x -> Sing ('Identity x)
newtype Par1 p = Par1 p
data instance Sing :: forall p. Par1 p -> Type where
SPar1 :: Sing x -> Sing ('Par1 x)
type family Rep1 (f :: Type -> Type) :: Type -> Type
class PGeneric1 (f :: Type -> Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: Type -> Type) where
sFrom1 :: forall (a :: Type) (z :: f a). Sing z -> Sing (From1 z)
sTo1 :: forall (a :: Type) (r :: Rep1 f a). Sing r -> Sing (To1 r :: f a)
type instance Rep1 Identity = Par1
instance PGeneric1 Identity where
type From1 ('Identity x) = 'Par1 x
type To1 ('Par1 x) = 'Identity x
instance SGeneric1 Identity where
sFrom1 (SIdentity x) = SPar1 x
sTo1 (SPar1 x) = SIdentity x
type family GenericMeth (x :: f a) :: f a where
GenericMeth x = To1 (Meth (From1 x))
type family Meth (x :: f a) :: f a
class SC f where
sMeth :: forall a (x :: f a).
Sing x -> Sing (Meth x)
default sMeth :: forall a (x :: f a).
( SGeneric1 f, SC (Rep1 f)
, Meth x ~ GenericMeth x
)
=> Sing x -> Sing (Meth x)
sMeth sx = sTo1 (sMeth (sFrom1 sx))
dummy :: f a -> ()
dummy _ = ()
type instance Meth (x :: Par1 p) = x
instance SC Par1 where
sMeth x = x
```
```
$ /opt/ghc/8.6.1/bin/ghc -fforce-recomp Bug.hs -dcore-lint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
[in body of letrec with binders x_s1Nw :: Sing (From1 x_a1Jc)]
Trans coercion mis-match: D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
Rep1 Identity a_a1Jb
Par1 a_a1Jb
Rep1 Identity a_a1Jb
Par1 a_a1Jb
*** Offending Program ***
<elided>
$csMeth_a1J9 [Occ=LoopBreaker]
:: forall a (x :: Identity a). Sing x -> Sing (Meth x)
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 100 60}]
$csMeth_a1J9
= \ (@ a_a1Jb) (@ (x_a1Jc :: Identity a_a1Jb)) ->
case heq_sel
@ (Identity a_a1Jb)
@ (Identity a_a1Jb)
@ (Meth x_a1Jc)
@ (GenericMeth x_a1Jc)
(($d~_s1Nz @ a_a1Jb @ x_a1Jc)
`cast` (((~)
<Identity a_a1Jb>_N
((To1
<Identity>_N
<a_a1Jb>_N
(Coh (Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
(Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N))))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))_N))_N ; (Sym (D:R:GenericMeth[0]
<Identity>_N
<a_a1Jb>_N
<x_a1Jc>_N) ; Sym (D:R:MethTYPEIdentityax[0]
<a_a1Jb>_N
<x_a1Jc>_N)))
((To1
<Identity>_N
<a_a1Jb>_N
(Coh (Sym (Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
(Coh (Sym (Coh <From1
x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N))) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Coh <From1
x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))_N)))_N ; Sym (D:R:GenericMeth[0]
<Identity>_N
<a_a1Jb>_N
<x_a1Jc>_N)))_R ; N:~[0]
<Identity
a_a1Jb>_N <Meth
x_a1Jc>_N <GenericMeth
x_a1Jc>_N
:: (To1 (From1 x_a1Jc) ~ To1 (From1 x_a1Jc))
~R# (Meth x_a1Jc ~~ GenericMeth x_a1Jc)))
of co_a1Kd
{ __DEFAULT ->
(\ (sx_aEZ :: Sing x_a1Jc) ->
let {
x_s1Nw :: Sing (From1 x_a1Jc)
[LclId]
x_s1Nw = $csFrom1_a1Jz @ a_a1Jb @ x_a1Jc sx_aEZ } in
case x_s1Nw
`cast` ((Sing
(D:R:Rep1Identity[0] <a_a1Jb>_N)
(Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))_R ; (Nth:3
(Inst (forall (x :: Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N).
(Sing
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
(Sym (Coh <x>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_R
->_R (Sing
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
(Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
<x>_N) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Sym (Coh <x>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_N))_R) (Coh <From1
x_a1Jc>_N
(Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))) ; ((Sing
(D:R:Rep1Identity[0] <a_a1Jb>_N))_R ; D:R:SingPar10[0]
<a_a1Jb>_N) (Sym (Coh <Meth
(From1
x_a1Jc)>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N))))
:: Sing (From1 x_a1Jc |> Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
~R# R:SingPar1
a_a1Jb (Meth (From1 x_a1Jc) |> D:R:Rep1Identity[0] <a_a1Jb>_N))
of
{ SPar1 @ x_a1JZ co_a1K0 x_a195 ->
($WSIdentity @ a_a1Jb @ x_a1JZ x_a195)
`cast` ((Sing
<Identity a_a1Jb>_N
(Sym (D:R:To1IdentityaPar1[0] <a_a1Jb>_N <x_a1JZ>_N) ; (To1
<Identity>_N
<a_a1Jb>_N
(Sym (Coh (Sym (Coh <'Par1
x_a1JZ>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)) ; (Coh <'Par1
x_a1JZ>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym co_a1K0 ; Coh <Meth
(From1
x_a1Jc)>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))))_N))_R
:: Sing ('Identity x_a1JZ) ~R# Sing (To1 (Meth (From1 x_a1Jc))))
})
`cast` (<Sing x_a1Jc>_R
->_R (Sing
<Identity a_a1Jb>_N
(Sym (D:R:GenericMeth[0]
<Identity>_N <a_a1Jb>_N <x_a1Jc>_N) ; Sym co_a1Kd))_R
:: (Sing x_a1Jc -> Sing (To1 (Meth (From1 x_a1Jc))))
~R# (Sing x_a1Jc -> Sing (Meth x_a1Jc)))
}
end Rec }
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.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":"Core Lint error: Trans coercion mis-match","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DefaultSignatures #-}\r\n{-# LANGUAGE FlexibleContexts #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Functor.Identity (Identity(..))\r\nimport Data.Kind (Type)\r\nimport GHC.Exts (Any)\r\n\r\n-----\r\n-- The important bits\r\n-----\r\n\r\ntype instance Meth (x :: Identity a) = GenericMeth x\r\ninstance SC Identity\r\n\r\n-------------------------------------------------------------------------------\r\n\r\ndata family Sing :: forall k. k -> Type\r\ndata instance Sing :: forall a. Identity a -> Type where\r\n SIdentity :: Sing x -> Sing ('Identity x)\r\n\r\nnewtype Par1 p = Par1 p\r\ndata instance Sing :: forall p. Par1 p -> Type where\r\n SPar1 :: Sing x -> Sing ('Par1 x)\r\n\r\ntype family Rep1 (f :: Type -> Type) :: Type -> Type\r\n\r\nclass PGeneric1 (f :: Type -> Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: Type -> Type) where\r\n sFrom1 :: forall (a :: Type) (z :: f a). Sing z -> Sing (From1 z)\r\n sTo1 :: forall (a :: Type) (r :: Rep1 f a). Sing r -> Sing (To1 r :: f a)\r\n\r\ntype instance Rep1 Identity = Par1\r\n\r\ninstance PGeneric1 Identity where\r\n type From1 ('Identity x) = 'Par1 x\r\n type To1 ('Par1 x) = 'Identity x\r\n\r\ninstance SGeneric1 Identity where\r\n sFrom1 (SIdentity x) = SPar1 x\r\n sTo1 (SPar1 x) = SIdentity x\r\n\r\ntype family GenericMeth (x :: f a) :: f a where\r\n GenericMeth x = To1 (Meth (From1 x))\r\n\r\ntype family Meth (x :: f a) :: f a\r\n\r\nclass SC f where\r\n sMeth :: forall a (x :: f a).\r\n Sing x -> Sing (Meth x)\r\n default sMeth :: forall a (x :: f a).\r\n ( SGeneric1 f, SC (Rep1 f)\r\n , Meth x ~ GenericMeth x\r\n )\r\n => Sing x -> Sing (Meth x)\r\n sMeth sx = sTo1 (sMeth (sFrom1 sx))\r\n\r\n dummy :: f a -> ()\r\n dummy _ = ()\r\n\r\ntype instance Meth (x :: Par1 p) = x\r\ninstance SC Par1 where\r\n sMeth x = x\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc -fforce-recomp Bug.hs -dcore-lint\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n [in body of letrec with binders x_s1Nw :: Sing (From1 x_a1Jc)]\r\n Trans coercion mis-match: D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n Rep1 Identity a_a1Jb\r\n Par1 a_a1Jb\r\n Rep1 Identity a_a1Jb\r\n Par1 a_a1Jb\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csMeth_a1J9 [Occ=LoopBreaker]\r\n :: forall a (x :: Identity a). Sing x -> Sing (Meth x)\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 100 60}]\r\n$csMeth_a1J9\r\n = \\ (@ a_a1Jb) (@ (x_a1Jc :: Identity a_a1Jb)) ->\r\n case heq_sel\r\n @ (Identity a_a1Jb)\r\n @ (Identity a_a1Jb)\r\n @ (Meth x_a1Jc)\r\n @ (GenericMeth x_a1Jc)\r\n (($d~_s1Nz @ a_a1Jb @ x_a1Jc)\r\n `cast` (((~)\r\n <Identity a_a1Jb>_N\r\n ((To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Coh (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))_N))_N ; (Sym (D:R:GenericMeth[0]\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N) ; Sym (D:R:MethTYPEIdentityax[0]\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N)))\r\n ((To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh <From1\r\n x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Coh <From1\r\n x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))_N)))_N ; Sym (D:R:GenericMeth[0]\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N)))_R ; N:~[0]\r\n <Identity\r\n a_a1Jb>_N <Meth\r\n x_a1Jc>_N <GenericMeth\r\n x_a1Jc>_N\r\n :: (To1 (From1 x_a1Jc) ~ To1 (From1 x_a1Jc))\r\n ~R# (Meth x_a1Jc ~~ GenericMeth x_a1Jc)))\r\n of co_a1Kd\r\n { __DEFAULT ->\r\n (\\ (sx_aEZ :: Sing x_a1Jc) ->\r\n let {\r\n x_s1Nw :: Sing (From1 x_a1Jc)\r\n [LclId]\r\n x_s1Nw = $csFrom1_a1Jz @ a_a1Jb @ x_a1Jc sx_aEZ } in\r\n case x_s1Nw\r\n `cast` ((Sing\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)\r\n (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))_R ; (Nth:3\r\n (Inst (forall (x :: Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N).\r\n (Sing\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n (Sym (Coh <x>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_R\r\n ->_R (Sing\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n <x>_N) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Sym (Coh <x>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_N))_R) (Coh <From1\r\n x_a1Jc>_N\r\n (Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))) ; ((Sing\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))_R ; D:R:SingPar10[0]\r\n <a_a1Jb>_N) (Sym (Coh <Meth\r\n (From1\r\n x_a1Jc)>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))))\r\n :: Sing (From1 x_a1Jc |> Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n ~R# R:SingPar1\r\n a_a1Jb (Meth (From1 x_a1Jc) |> D:R:Rep1Identity[0] <a_a1Jb>_N))\r\n of\r\n { SPar1 @ x_a1JZ co_a1K0 x_a195 ->\r\n ($WSIdentity @ a_a1Jb @ x_a1JZ x_a195)\r\n `cast` ((Sing\r\n <Identity a_a1Jb>_N\r\n (Sym (D:R:To1IdentityaPar1[0] <a_a1Jb>_N <x_a1JZ>_N) ; (To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Sym (Coh (Sym (Coh <'Par1\r\n x_a1JZ>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)) ; (Coh <'Par1\r\n x_a1JZ>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym co_a1K0 ; Coh <Meth\r\n (From1\r\n x_a1Jc)>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))))_N))_R\r\n :: Sing ('Identity x_a1JZ) ~R# Sing (To1 (Meth (From1 x_a1Jc))))\r\n })\r\n `cast` (<Sing x_a1Jc>_R\r\n ->_R (Sing\r\n <Identity a_a1Jb>_N\r\n (Sym (D:R:GenericMeth[0]\r\n <Identity>_N <a_a1Jb>_N <x_a1Jc>_N) ; Sym co_a1Kd))_R\r\n :: (Sing x_a1Jc -> Sing (To1 (Meth (From1 x_a1Jc))))\r\n ~R# (Sing x_a1Jc -> Sing (Meth x_a1Jc)))\r\n }\r\nend Rec }\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15778GHC HEAD-only panic (zonkTcTyVarToTyVar)2019-07-07T18:03:02ZRyan ScottGHC HEAD-only panic (zonkTcTyVarToTyVar)The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUA...The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind
type a ~> b = a -> b -> Type
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing (a :: k)
data Flarble (a :: Type) where
MkFlarble :: Flarble Bool
data instance Sing (z :: Flarble a) where
SMkFlarble :: Sing MkFlarble
elimFlarble :: forall a
(p :: forall x. Flarble x ~> Type)
(f :: Flarble a).
Sing f
-> Apply p MkFlarble
-> Apply p f
elimFlarble s@SMkFlarble pMkFlarble =
case s of
(_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) ->
pMkFlarble
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181015 for x86_64-unknown-linux):
zonkTcTyVarToTyVar
probablyABadIdea_aWn[tau:2]
Bool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType
```
If I replace `probablyABadIdea` with `Bool`, then it typechecks again.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.5 |
| 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":"GHC HEAD-only panic (zonkTcTyVarToTyVar)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.0.1 through 8.6.1:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE AllowAmbiguousTypes #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype a ~> b = a -> b -> Type\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ndata family Sing (a :: k)\r\n\r\ndata Flarble (a :: Type) where\r\n MkFlarble :: Flarble Bool\r\ndata instance Sing (z :: Flarble a) where\r\n SMkFlarble :: Sing MkFlarble\r\n\r\nelimFlarble :: forall a\r\n (p :: forall x. Flarble x ~> Type)\r\n (f :: Flarble a).\r\n Sing f\r\n -> Apply p MkFlarble\r\n -> Apply p f\r\nelimFlarble s@SMkFlarble pMkFlarble =\r\n case s of\r\n (_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) ->\r\n pMkFlarble\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181015 for x86_64-unknown-linux):\r\n zonkTcTyVarToTyVar\r\n probablyABadIdea_aWn[tau:2]\r\n Bool\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType\r\n}}}\r\n\r\nIf I replace `probablyABadIdea` with `Bool`, then it typechecks again.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15853Unregisterised GHC panics when building test cgrun0182019-07-07T18:02:43ZIlias TsitsimpisUnregisterised GHC panics when building test cgrun018An unregisterised ghc-8.4 on amd64 panics when building test cgrun018.
```
Compile failed (exit code 1) errors were:
[1 of 1] Compiling Main ( cgrun018.hs, cgrun018.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC v...An unregisterised ghc-8.4 on amd64 panics when building test cgrun018.
```
Compile failed (exit code 1) errors were:
[1 of 1] Compiling Main ( cgrun018.hs, cgrun018.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.4.4 for x86_64-unknown-linux):
pprStatics: float
F32
F32
F32
F32
F32
F32
F32
F32
F32
F32
F32
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/cmm/PprC.hs:525:5 in ghc:PprC
```
We have seen this error while building packages for Debian on 64-bit architectures where GHC is unregisterised (e.g., mips64el, s390x):
[gloss on mips64el](https://buildd.debian.org/status/fetch.php?pkg=haskell-gloss&arch=mips64el&ver=1.13.0.1-1&stamp=1540810998&raw=0),
[juicypixels on s390x](https://buildd.debian.org/status/fetch.php?pkg=haskell-juicypixels&arch=s390x&ver=3.2.9.5-3&stamp=1540808360&raw=0)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------------ |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (CodeGen) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Unregisterised GHC panics when building test cgrun018","status":"New","operating_system":"","component":"Compiler (CodeGen)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"An unregisterised ghc-8.4 on amd64 panics when building test cgrun018.\r\n\r\n{{{\r\nCompile failed (exit code 1) errors were:\r\n[1 of 1] Compiling Main ( cgrun018.hs, cgrun018.o )\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.4.4 for x86_64-unknown-linux):\r\n pprStatics: float\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n F32\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/cmm/PprC.hs:525:5 in ghc:PprC\r\n}}}\r\n\r\nWe have seen this error while building packages for Debian on 64-bit architectures where GHC is unregisterised (e.g., mips64el, s390x):\r\n[https://buildd.debian.org/status/fetch.php?pkg=haskell-gloss&arch=mips64el&ver=1.13.0.1-1&stamp=1540810998&raw=0 gloss on mips64el],\r\n[https://buildd.debian.org/status/fetch.php?pkg=haskell-juicypixels&arch=s390x&ver=3.2.9.5-3&stamp=1540808360&raw=0 juicypixels on s390x]","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15862Panic with promoted types that Typeable doesn't support2020-02-25T01:15:47ZRyan ScottPanic with promoted types that Typeable doesn't supportThe following program panics on GHC 8.2 and later:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Bug where
import Type.Reflection
newtype Foo ...The following program panics on GHC 8.2 and later:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Bug where
import Type.Reflection
newtype Foo = MkFoo (forall a. a)
foo :: TypeRep MkFoo
foo = typeRep @MkFoo
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
GHC error in desugarer lookup in Bug:
attempting to use module ‘main:Bug’ (Bug.hs) which is not loaded
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64-unknown-linux):
initDs
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.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":"Typeable panic with promoted rank-2 kind (initDs)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["Typeable"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC 8.2 and later:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds #-}\r\n{-# LANGUAGE ImpredicativeTypes #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE TypeApplications #-}\r\nmodule Bug where\r\n\r\nimport Type.Reflection\r\n\r\nnewtype Foo = MkFoo (forall a. a)\r\n\r\nfoo :: TypeRep MkFoo\r\nfoo = typeRep @MkFoo\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nGHC error in desugarer lookup in Bug:\r\n attempting to use module ‘main:Bug’ (Bug.hs) which is not loaded\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.1 for x86_64-unknown-linux):\r\n initDs\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Ryan ScottRyan Scotthttps://gitlab.haskell.org/ghc/ghc/-/issues/16188GHC HEAD-only panic (buildKindCoercion)2019-07-07T18:01:01ZRyan ScottGHC HEAD-only panic (buildKindCoercion)The following program compiles without issue on GHC 8.6.3:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators ...The following program compiles without issue on GHC 8.6.3:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind (Type)
import Data.Type.Bool (type (&&))
data TyFun :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type family Apply (f :: a ~> b) (x :: a) :: b
data family Sing :: forall k. k -> Type
data instance Sing :: Bool -> Type where
SFalse :: Sing False
STrue :: Sing True
(%&&) :: forall (x :: Bool) (y :: Bool).
Sing x -> Sing y -> Sing (x && y)
SFalse %&& _ = SFalse
STrue %&& a = a
data RegExp :: Type -> Type where
App :: RegExp t -> RegExp t -> RegExp t
data instance Sing :: forall t. RegExp t -> Type where
SApp :: Sing re1 -> Sing re2 -> Sing (App re1 re2)
data ReNotEmptySym0 :: forall t. RegExp t ~> Bool
type instance Apply ReNotEmptySym0 r = ReNotEmpty r
type family ReNotEmpty (r :: RegExp t) :: Bool where
ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2
sReNotEmpty :: forall t (r :: RegExp t).
Sing r -> Sing (Apply ReNotEmptySym0 r :: Bool)
sReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2
blah :: forall (t :: Type) (re :: RegExp t).
Sing re -> ()
blah (SApp sre1 sre2)
= case (sReNotEmpty sre1, sReNotEmpty sre2) of
(STrue, STrue) -> ()
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.7.20190114 for x86_64-unknown-linux):
buildKindCoercion
Any
ReNotEmpty re2_a1hm
Bool
t_a1hg
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.7 |
| 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":"GHC HEAD-only panic (buildKindCoercion)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program compiles without issue on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\nimport Data.Type.Bool (type (&&))\r\n\r\ndata TyFun :: Type -> Type -> Type\r\ntype a ~> b = TyFun a b -> Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: a ~> b) (x :: a) :: b\r\ndata family Sing :: forall k. k -> Type\r\n\r\ndata instance Sing :: Bool -> Type where\r\n SFalse :: Sing False\r\n STrue :: Sing True\r\n\r\n(%&&) :: forall (x :: Bool) (y :: Bool).\r\n Sing x -> Sing y -> Sing (x && y)\r\nSFalse %&& _ = SFalse\r\nSTrue %&& a = a\r\n\r\ndata RegExp :: Type -> Type where\r\n App :: RegExp t -> RegExp t -> RegExp t\r\n\r\ndata instance Sing :: forall t. RegExp t -> Type where\r\n SApp :: Sing re1 -> Sing re2 -> Sing (App re1 re2)\r\n\r\ndata ReNotEmptySym0 :: forall t. RegExp t ~> Bool\r\ntype instance Apply ReNotEmptySym0 r = ReNotEmpty r\r\n\r\ntype family ReNotEmpty (r :: RegExp t) :: Bool where\r\n ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2\r\n\r\nsReNotEmpty :: forall t (r :: RegExp t).\r\n Sing r -> Sing (Apply ReNotEmptySym0 r :: Bool)\r\nsReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2\r\n\r\nblah :: forall (t :: Type) (re :: RegExp t).\r\n Sing re -> ()\r\nblah (SApp sre1 sre2)\r\n = case (sReNotEmpty sre1, sReNotEmpty sre2) of\r\n (STrue, STrue) -> ()\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20190114 for x86_64-unknown-linux):\r\n buildKindCoercion\r\n Any\r\n ReNotEmpty re2_a1hm\r\n Bool\r\n t_a1hg\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/16204GHC HEAD-only Core Lint error (Argument value doesn't match argument type)2019-07-07T18:00:58ZRyan ScottGHC HEAD-only Core Lint error (Argument value doesn't match argument type)The following program passes Core Lint on GHC 8.6.3:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{...The following program passes Core Lint on GHC 8.6.3:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Kind
-----
-- singletons machinery
-----
data family Sing :: forall k. k -> Type
data SomeSing :: Type -> Type where
SomeSing :: Sing (a :: k) -> SomeSing k
-----
-- (Simplified) GHC.Generics
-----
class Generic (a :: Type) where
type Rep a :: Type
from :: a -> Rep a
to :: Rep a -> a
class PGeneric (a :: Type) where
-- type PFrom ...
type PTo (x :: Rep a) :: a
class SGeneric k where
-- sFrom :: ...
sTo :: forall (a :: Rep k). Sing a -> Sing (PTo a :: k)
-----
class SingKind k where
type Demote k :: Type
-- fromSing :: ...
toSing :: Demote k -> SomeSing k
genericToSing :: forall k.
( SingKind k, SGeneric k, SingKind (Rep k)
, Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )
=> Demote k -> SomeSing k
genericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo
withSomeSing :: forall k r
. SingKind k
=> Demote k
-> (forall (a :: k). Sing a -> r)
-> r
withSomeSing x f =
case toSing x of
SomeSing x' -> f x'
```
But not on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug.hs -dcore-lint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: $ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) ->
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
->_R <Sing (PTo Any)>_R
:: (Sing Any -> Sing (PTo Any))
~R# (Sing Any -> Sing (PTo Any)))))
Argument value doesn't match argument type:
Fun type:
(forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)
-> SomeSing k_a1cV
Arg type: forall (a :: Rep k_a1cV). Sing Any -> SomeSing k_a1cV
Arg:
\ (@ (a_a1dc :: Rep k_a1cV)) ->
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
->_R <Sing (PTo Any)>_R
:: (Sing Any -> Sing (PTo Any)) ~R# (Sing Any -> Sing (PTo Any))))
*** Offending Program ***
<elided>
genericToSing
:: forall k.
(SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),
Rep (Demote k) ~ Demote (Rep k)) =>
Demote k -> SomeSing k
[LclIdX]
genericToSing
= \ (@ k_a1cV)
($dSingKind_a1cX :: SingKind k_a1cV)
($dSGeneric_a1cY :: SGeneric k_a1cV)
($dSingKind_a1cZ :: SingKind (Rep k_a1cV))
($dGeneric_a1d0 :: Generic (Demote k_a1cV))
($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) ->
let {
co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in
let {
co_a1dO :: Rep k_a1cV ~# Rep k_a1cV
[LclId[CoVarId]]
co_a1dO = CO: <Rep k_a1cV>_N } in
let {
$dSingKind_a1dT :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1dT
= $dSingKind_a1cZ
`cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
$dSingKind_a1d5 :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1d5
= $dSingKind_a1dT
`cast` ((SingKind (Sym co_a1dO))_R
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)
[LclId[CoVarId]]
co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in
let {
co_a1dK :: Demote k_a1cV ~# Demote k_a1cV
[LclId[CoVarId]]
co_a1dK = CO: <Demote k_a1cV>_N } in
let {
$dGeneric_a1dU :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1dU
= $dGeneric_a1d0
`cast` (Sub (Sym (Generic (Sym co_a1dK))_N)
:: Generic (Demote k_a1cV[sk:1])
~R# Generic (Demote k_a1cV[sk:1])) } in
let {
$dGeneric_a1d7 :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1d7 = $dGeneric_a1dU } in
case eq_sel
@ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1
of co_a1dI
{ __DEFAULT ->
let {
co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dR
= CO: ((Sym co_a1dM ; (Rep
(Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N) } in
\ (d_aX7 :: Demote k_a1cV) ->
$ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) ->
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
->_R <Sing (PTo Any)>_R
:: (Sing Any -> Sing (PTo Any)) ~R# (Sing Any -> Sing (PTo Any)))))
}
```
I'm not sure if this is related to #16188 (see #16188\##16204), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #16188 |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC HEAD-only Core Lint error (Argument value doesn't match argument type)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[16188],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program passes Core Lint on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds #-}\r\n{-# LANGUAGE FlexibleContexts #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\n-----\r\n-- singletons machinery\r\n-----\r\n\r\ndata family Sing :: forall k. k -> Type\r\ndata SomeSing :: Type -> Type where\r\n SomeSing :: Sing (a :: k) -> SomeSing k\r\n\r\n-----\r\n-- (Simplified) GHC.Generics\r\n-----\r\n\r\nclass Generic (a :: Type) where\r\n type Rep a :: Type\r\n from :: a -> Rep a\r\n to :: Rep a -> a\r\n\r\nclass PGeneric (a :: Type) where\r\n -- type PFrom ...\r\n type PTo (x :: Rep a) :: a\r\n\r\nclass SGeneric k where\r\n -- sFrom :: ...\r\n sTo :: forall (a :: Rep k). Sing a -> Sing (PTo a :: k)\r\n\r\n-----\r\n\r\nclass SingKind k where\r\n type Demote k :: Type\r\n -- fromSing :: ...\r\n toSing :: Demote k -> SomeSing k\r\n\r\ngenericToSing :: forall k.\r\n ( SingKind k, SGeneric k, SingKind (Rep k)\r\n , Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )\r\n => Demote k -> SomeSing k\r\ngenericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo\r\n\r\nwithSomeSing :: forall k r\r\n . SingKind k\r\n => Demote k\r\n -> (forall (a :: k). Sing a -> r)\r\n -> r\r\nwithSomeSing x f =\r\n case toSing x of\r\n SomeSing x' -> f x'\r\n}}}\r\n\r\nBut not on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug.hs -dcore-lint \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) ->\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n ->_R <Sing (PTo Any)>_R\r\n :: (Sing Any -> Sing (PTo Any))\r\n ~R# (Sing Any -> Sing (PTo Any)))))\r\n Argument value doesn't match argument type:\r\n Fun type:\r\n (forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)\r\n -> SomeSing k_a1cV\r\n Arg type: forall (a :: Rep k_a1cV). Sing Any -> SomeSing k_a1cV\r\n Arg:\r\n \\ (@ (a_a1dc :: Rep k_a1cV)) ->\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n ->_R <Sing (PTo Any)>_R\r\n :: (Sing Any -> Sing (PTo Any)) ~R# (Sing Any -> Sing (PTo Any))))\r\n*** Offending Program ***\r\n<elided>\r\ngenericToSing\r\n :: forall k.\r\n (SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),\r\n Rep (Demote k) ~ Demote (Rep k)) =>\r\n Demote k -> SomeSing k\r\n[LclIdX]\r\ngenericToSing\r\n = \\ (@ k_a1cV)\r\n ($dSingKind_a1cX :: SingKind k_a1cV)\r\n ($dSGeneric_a1cY :: SGeneric k_a1cV)\r\n ($dSingKind_a1cZ :: SingKind (Rep k_a1cV))\r\n ($dGeneric_a1d0 :: Generic (Demote k_a1cV))\r\n ($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) ->\r\n let {\r\n co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in\r\n let {\r\n co_a1dO :: Rep k_a1cV ~# Rep k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dO = CO: <Rep k_a1cV>_N } in\r\n let {\r\n $dSingKind_a1dT :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1dT\r\n = $dSingKind_a1cZ\r\n `cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n $dSingKind_a1d5 :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1d5\r\n = $dSingKind_a1dT\r\n `cast` ((SingKind (Sym co_a1dO))_R\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in\r\n let {\r\n co_a1dK :: Demote k_a1cV ~# Demote k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dK = CO: <Demote k_a1cV>_N } in\r\n let {\r\n $dGeneric_a1dU :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1dU\r\n = $dGeneric_a1d0\r\n `cast` (Sub (Sym (Generic (Sym co_a1dK))_N)\r\n :: Generic (Demote k_a1cV[sk:1])\r\n ~R# Generic (Demote k_a1cV[sk:1])) } in\r\n let {\r\n $dGeneric_a1d7 :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1d7 = $dGeneric_a1dU } in\r\n case eq_sel\r\n @ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1\r\n of co_a1dI\r\n { __DEFAULT ->\r\n let {\r\n co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dR\r\n = CO: ((Sym co_a1dM ; (Rep\r\n (Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N) } in\r\n \\ (d_aX7 :: Demote k_a1cV) ->\r\n $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a -> SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) ->\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n ->_R <Sing (PTo Any)>_R\r\n :: (Sing Any -> Sing (PTo Any)) ~R# (Sing Any -> Sing (PTo Any)))))\r\n }\r\n}}}\r\n\r\nI'm not sure if this is related to #16188 (see https://ghc.haskell.org/trac/ghc/ticket/16188#comment:1), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/16509GHCI panics: isUnliftedType2019-08-15T09:30:53ZAlex DGHCI panics: isUnliftedTypeGHC panics when the following program is loaded in ghci:
```haskell
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module PatternPanic
(
Outer(..),
Inner(..),
pattern TestPat
) where
data Oute...GHC panics when the following program is loaded in ghci:
```haskell
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module PatternPanic
(
Outer(..),
Inner(..),
pattern TestPat
) where
data Outer = Outer Inner Inner
data Inner = Inner Int Int
pattern TestPat :: String -> String -> Outer
pattern TestPat ref1 ref2 <-
Outer (Inner (extractRef -> Just ref1)
(extractRef -> Just ref2)
)
(Inner (isSameRef ref1 -> True)
(isSameRef ref2 -> True)
)
------------ Helper functions ------------
extractRef :: Int -> Maybe String
extractRef 0 = Nothing
extractRef v = Just $ show v
isSameRef :: String -> Int -> Bool
isSameRef refName e
| Just refName2 <- extractRef e
= refName == refName2
isSameRef _ _ = False
-- Note that the GHC panic does not happen if 'isSameRef' is replaced with the following version.
-- isSameRef :: String -> Int -> Bool
-- isSameRef refName e =
-- extractRef e == Just refName
```
Returns
```
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
Prelude> :l PatternPanic.hs
[1 of 1] Compiling PatternPanic ( PatternPanic.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64-apple-darwin):
isUnliftedType
r_a2Qa :: TYPE rep_a2Q9
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:2021:10 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This simplified code snippet was extracted from a relatively large codebase (~180k LOC). Note, that we would get the same error when we try to compile this application with `-O2` with ghc > 8.4. Unfortunately, I am not able to reproduce compilation failure with this minimal example, though.
I tried it with `GHC 8.9.20190323 x86_64-apple-darwin` - same error.
#14828 looks quite similar.
[pattern-panic.zip](/uploads/131454dd8e8815c72f87666db8c7f63f/pattern-panic.zip)8.8.1