GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2020-07-17T19:06:27Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/17312Potentially unnecessary warning about missing deriving strategies2020-07-17T19:06:27ZtaylorfausakPotentially unnecessary warning about missing deriving strategies## Summary
I'm not sure if this is a bug or not. I ran into it when compiling code using GHC 8.8.1 and `-Weverything`. I was surprised to find that `-Wmissing-deriving-strategies` fires even when there is no ambiguity about which derivi...## Summary
I'm not sure if this is a bug or not. I ran into it when compiling code using GHC 8.8.1 and `-Weverything`. I was surprised to find that `-Wmissing-deriving-strategies` fires even when there is no ambiguity about which deriving strategy should be used. In other words, with no language extensions enabled, (I think) `stock` is the only valid deriving strategy. Therefore I would not expect this warning to fire. I would expect this warning to fire if I had `GeneralizedNewtypeDeriving`, `DeriveAnyClass`, `DerivingStrategies`, or `DerivingVia` enabled.
## Steps to reproduce
``` sh
$ ghc -Wmissing-deriving-strategies -e 'data T = C deriving Eq'
```
```
<interactive>:0:12: warning: [-Wmissing-deriving-strategies]
No deriving strategy specified. Did you want stock, newtype, or anyclass?
Use DerivingStrategies to specify a strategy.
```
## Expected behavior
I expected no warning because the `deriving` clause is not ambiguous.
## Environment
* GHC version used: 8.8.1
Optional:
* Operating System: Windows 10
* System Architecture: x86_648.8.2https://gitlab.haskell.org/ghc/ghc/-/issues/17260Link to Haddocks for Language.Haskell.TH is broken2023-10-03T15:53:24ZadamLink to Haddocks for Language.Haskell.TH is brokenThe link to the haddocks in the [users guide][1] is broken: <https://downloads.haskell.org/ghc/latest/docs/html/libraries/template-haskell-@LIBRARY_template_haskell_VERSION@/Haddock%20reference%20documentation%20%3CLanguage-Haskell-TH.ht...The link to the haddocks in the [users guide][1] is broken: <https://downloads.haskell.org/ghc/latest/docs/html/libraries/template-haskell-@LIBRARY_template_haskell_VERSION@/Haddock%20reference%20documentation%20%3CLanguage-Haskell-TH.html#v:%3E>
[1]: https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#template-haskell8.8.2Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/17057Partially applied type family causes GHC internal error since GHC 8.82020-02-25T01:11:30Zsheafsam.derbyshire@gmail.comPartially applied type family causes GHC internal error since GHC 8.8On GHC 8.8.0.20190721, the following program
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies ...On GHC 8.8.0.20190721, the following program
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
module Bug where
import Data.Kind
( Type )
import Data.Proxy
( Proxy(Proxy) )
data HList :: [Type] -> Type where
type family Foo (xs :: [Type]) (ys :: [Type]) :: [Type] where
foo :: forall (is :: [Type]). HList is -> HList (Foo is)
foo = case Proxy @is of
_ -> undefined
```
causes a GHC internal error:
```
bug.hs:21:50: error:
* Expecting one more argument to `Foo is'
Expected kind `[*]', but `Foo is' has kind `[*] -> [*]'
* In the first argument of `HList', namely `(Foo is)'
In the type signature:
foo :: forall (is :: [Type]). HList is -> HList (Foo is)
|
21 | foo :: forall (is :: [Type]). HList is -> HList (Foo is)
|
bug.hs:22:19: error:
* GHC internal error: `is' is not in scope during type checking, but it passed the renamer
tcl_env of environment: []
* In the type `is'
In the expression: Proxy @is
In the expression: case Proxy @is of { _ -> undefined }
|
22 | foo = case Proxy @is of
| ^^
```
On GHC 8.6.5, the internal error does not occur and as expected we simply get an error for a partially applied type family.
```
bug.hs:21:50: error:
* Expecting one more argument to `Foo is'
Expected kind `[*]', but `Foo is' has kind `[*] -> [*]'
* In the first argument of `HList', namely `(Foo is)'
In the type signature:
foo :: forall (is :: [Type]). HList is -> HList (Foo is)
|
21 | foo :: forall (is :: [Type]). HList is -> HList (Foo is)
|
```
This came up after I had modified a type family by adding an extra argument, and had forgotten to pass in that extra argument somewhere.8.8.2https://gitlab.haskell.org/ghc/ghc/-/issues/17036expose minf_rdr_env2019-12-06T20:03:03ZSam Hallidayexpose minf_rdr_env## Motivation
The `GlobalRdrEnv` of a module is very useful for tooling authors, see https://gitlab.com/tseenshe/hsinspect/blob/503cd48faba5b308be29ed44a12f7d6b22105f2b/exe/Main.hs#L53-61 for a working example.
However, `minf_rdr_env` ...## Motivation
The `GlobalRdrEnv` of a module is very useful for tooling authors, see https://gitlab.com/tseenshe/hsinspect/blob/503cd48faba5b308be29ed44a12f7d6b22105f2b/exe/Main.hs#L53-61 for a working example.
However, `minf_rdr_env` is not exposed (an oversight?) so users of the api must invoke a full typecheck phase on the full file (or manually parse just the import section).
## Proposal
Adding and exporting the following from `GHC.hs`
```
modInfoRdrEnv :: ModuleInfo -> Maybe GlobalRdrEnv
modInfoRdrEnv = minf_rdr_env
```
Would it make sense to backport this for any upcoming 8.6 releases?8.8.2https://gitlab.haskell.org/ghc/ghc/-/issues/16387Duplicate vsnwprintf symbol on Windows2019-11-08T20:29:02ZBen GamariDuplicate vsnwprintf symbol on WindowsLeading to failure of `T5836`:
```
Stderr ( T5836 ):
GHC runtime linker: fatal error: I found a duplicate definition for symbol
__mingw_vsnwprintf
whilst processing object file
C:\GitLabRunner\builds\8fc0e283\0\ghc\ghc\inplace\min...Leading to failure of `T5836`:
```
Stderr ( T5836 ):
GHC runtime linker: fatal error: I found a duplicate definition for symbol
__mingw_vsnwprintf
whilst processing object file
C:\GitLabRunner\builds\8fc0e283\0\ghc\ghc\inplace\mingw\x86_64-w64-mingw32\lib\libmingwex.a
The symbol was previously defined in
(GHCi built-in symbols)
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
ghc-stage2.exe: panic! (the 'impossible' happened)
(GHC version 8.9.20190303 for x86_64-unknown-mingw32):
loadArchive "C:\\GitLabRunner\\builds\\8fc0e283\\0\\ghc\\ghc\\inplace\\mingw\\x86_64-w64-mingw32\\lib\\libmingwex.a": failed
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
*** unexpected failure for T5836(ghci)
```8.8.2https://gitlab.haskell.org/ghc/ghc/-/issues/16288Core Lint error: Occurrence is GlobalId, but binding is LocalId2020-01-16T20:05:04ZKrzysztof GogolewskiCore Lint error: Occurrence is GlobalId, but binding is LocalIdCompiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)
To reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Rep...Compiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)
To reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Repro/B.hs`. The reproduction code is minimized version of code from cabal and prettyprint libraries.
A.hs
```haskell
module Repro.A where
import Repro.C
data License
class Pretty a where
pretty :: a -> Doc
instance Pretty License where
pretty _ = pretV
bar :: (Pretty a) => a -> Doc
bar w = foo (pretty (u w w w w))
u :: a -> a -> a -> a -> a
u = u
```
B.hs
```haskell
module Repro.B where
import Repro.A
import Repro.C
bar2 :: License -> Doc
bar2 = bar
```
C.hs
```haskell
module Repro.C where
data Doc = Empty | Beside Doc
hcat :: Doc -> Doc
hcat Empty = Empty
hcat xs = hcat xs
pretV = hcat Empty
foo :: Doc -> Doc
foo Empty = hcat Empty
foo val = Beside val
```
The error:
```
*** Core Lint errors : in result of Simplifier ***
Repro/C.hs:9:1: warning:
[in body of letrec with binders pretV_r3 :: Doc]
Occurrence is GlobalId, but binding is LocalId
pretV :: Doc
[GblId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]
*** Offending Program ***
lvl_s1kN :: Doc
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=True, Expandable=False, Guidance=IF_ARGS [] 30 20}]
lvl_s1kN
= case pretV of wild_Xd {
Empty -> pretV;
Beside ipv_s105 -> Beside wild_Xd
}
$sbar_s1kL [InlPrag=NOUSERINLINE[2]] :: License -> Doc
[LclId,
Arity=1,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)
Tmpl= \ _ [Occ=Dead] ->
case pretV of wild_Xd [Occ=Once*] {
Empty ->
let {
pretV_r3 :: Doc
[LclId]
pretV_r3 = wild_Xd } in
pretV;
Beside _ [Occ=Dead] -> Beside wild_Xd
}}]
$sbar_s1kL = \ _ [Occ=Dead] -> lvl_s1kN
$trModule_s1kE :: Addr#
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$trModule_s1kE = "main"#
$trModule_s1kF :: TrName
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s1kF = TrNameS $trModule_s1kE
$trModule_s1kG :: Addr#
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}]
$trModule_s1kG = "Repro.B"#
$trModule_s1kH :: TrName
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s1kH = TrNameS $trModule_s1kG
$trModule :: Module
[LclIdX,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$trModule = Module $trModule_s1kF $trModule_s1kH
bar2 :: License -> Doc
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 20}]
bar2
= \ _ [Occ=Dead] ->
case pretV of wild_Xd {
Empty -> pretV;
Beside ipv_s105 -> Beside wild_Xd
}
*** End of Offense ***
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | aspiwack |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Core Lint error: Occurrence is GlobalId, but binding is LocalId","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["aspiwack"],"type":"Bug","description":"Compiling the following three modules causes a Core Lint error in HEAD. (This does not happen in 8.6 - the Lint check was introduced later.)\r\n\r\nTo reproduce: save the three files in `Repro/` directory and use `ghc-stage2 -dcore-lint -O Repro/B.hs`. The reproduction code is minimized version of code from cabal and prettyprint libraries.\r\n\r\nA.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.A where\r\n\r\nimport Repro.C\r\n\r\ndata License\r\n\r\nclass Pretty a where\r\n pretty :: a -> Doc\r\n\r\ninstance Pretty License where\r\n pretty _ = pretV\r\n\r\nbar :: (Pretty a) => a -> Doc\r\nbar w = foo (pretty (u w w w w))\r\n\r\nu :: a -> a -> a -> a -> a\r\nu = u\r\n}}}\r\n\r\nB.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.B where\r\n\r\nimport Repro.A\r\nimport Repro.C\r\n\r\nbar2 :: License -> Doc\r\nbar2 = bar\r\n}}}\r\n\r\nC.hs\r\n\r\n{{{\r\n#!haskell\r\nmodule Repro.C where\r\n\r\ndata Doc = Empty | Beside Doc\r\n\r\nhcat :: Doc -> Doc\r\nhcat Empty = Empty\r\nhcat xs = hcat xs\r\n\r\npretV = hcat Empty\r\n\r\nfoo :: Doc -> Doc\r\nfoo Empty = hcat Empty\r\nfoo val = Beside val\r\n}}}\r\n\r\nThe error:\r\n\r\n{{{\r\n*** Core Lint errors : in result of Simplifier ***\r\nRepro/C.hs:9:1: warning:\r\n [in body of letrec with binders pretV_r3 :: Doc]\r\n Occurrence is GlobalId, but binding is LocalId\r\n pretV :: Doc\r\n [GblId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]\r\n*** Offending Program ***\r\nlvl_s1kN :: Doc\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=True, Expandable=False, Guidance=IF_ARGS [] 30 20}]\r\nlvl_s1kN\r\n = case pretV of wild_Xd {\r\n Empty -> pretV;\r\n Beside ipv_s105 -> Beside wild_Xd\r\n }\r\n\r\n$sbar_s1kL [InlPrag=NOUSERINLINE[2]] :: License -> Doc\r\n[LclId,\r\n Arity=1,\r\n Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)\r\n Tmpl= \\ _ [Occ=Dead] ->\r\n case pretV of wild_Xd [Occ=Once*] {\r\n Empty ->\r\n let {\r\n pretV_r3 :: Doc\r\n [LclId]\r\n pretV_r3 = wild_Xd } in\r\n pretV;\r\n Beside _ [Occ=Dead] -> Beside wild_Xd\r\n }}]\r\n$sbar_s1kL = \\ _ [Occ=Dead] -> lvl_s1kN\r\n\r\n$trModule_s1kE :: Addr#\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]\r\n$trModule_s1kE = \"main\"#\r\n\r\n$trModule_s1kF :: TrName\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]\r\n$trModule_s1kF = TrNameS $trModule_s1kE\r\n\r\n$trModule_s1kG :: Addr#\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}]\r\n$trModule_s1kG = \"Repro.B\"#\r\n\r\n$trModule_s1kH :: TrName\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]\r\n$trModule_s1kH = TrNameS $trModule_s1kG\r\n\r\n$trModule :: Module\r\n[LclIdX,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]\r\n$trModule = Module $trModule_s1kF $trModule_s1kH\r\n\r\nbar2 :: License -> Doc\r\n[LclIdX,\r\n Arity=1,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 20}]\r\nbar2\r\n = \\ _ [Occ=Dead] ->\r\n case pretV of wild_Xd {\r\n Empty -> pretV;\r\n Beside ipv_s105 -> Beside wild_Xd\r\n }\r\n\r\n*** End of Offense ***\r\n\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.2