GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:18:59Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/13986TypeApplications causes parse errors in @-patterns with certain Unicode chara...2019-07-07T18:18:59ZTikhonTypeApplications causes parse errors in @-patterns with certain Unicode charactersThe following function definition works without TypeApplications but fails to parse with the extension enabled:
```hs
{-# LANGUAGE TypeApplications #-}
module Mininal where
foo x₁@True = 10
```
It also parses correctly with "x" in pla...The following function definition works without TypeApplications but fails to parse with the extension enabled:
```hs
{-# LANGUAGE TypeApplications #-}
module Mininal where
foo x₁@True = 10
```
It also parses correctly with "x" in place of "x₁".
Parse error:
```
Minimal.hs:5:1-11: error: …
Parse error in pattern: foo x₁ @True
Compilation failed.
```8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13985GHC 8.0 regression: ‘k’ is not in scope during type checking, but it passed t...2019-07-07T18:19:00ZRyan ScottGHC 8.0 regression: ‘k’ is not in scope during type checking, but it passed the renamer```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Proxy
data family Fam
data instance Fam = MkFam (forall (a :: k). Proxy a)
```
On GHC 8.0.1, 8.0.2, 8.2.1, and HEA...```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Proxy
data family Fam
data instance Fam = MkFam (forall (a :: k). Proxy a)
```
On GHC 8.0.1, 8.0.2, 8.2.1, and HEAD, this fails with a GHC internal error:
```
$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:9:41: error:
• GHC internal error: ‘k’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [r1vy :-> APromotionErr FamDataConPE]
• In the kind ‘k’
In the type ‘(forall (a :: k). Proxy a)’
In the definition of data constructor ‘MkFam’
|
9 | data instance Fam = MkFam (forall (a :: k). Proxy a)
| ^
```
This is a regression, since on GHC 7.10.3, it did not crash:
```
$ /opt/ghc/7.10.3/bin/ghci Bug.hs
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:9:21:
Data constructor ‘MkFam’ has existential type variables, a context, or a specialised result type
MkFam :: forall (k :: BOX).
(forall (k :: BOX) (a :: k). Proxy a) -> Fam
(Use ExistentialQuantification or GADTs to allow this)
In the definition of data constructor ‘MkFam’
In the data instance declaration for ‘Fam’
```
This smells like #13738, but no `TypeApplications` are involved here, so I decided to open a separate ticket to be safe.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #13738 |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC 8.0 regression: ‘k’ is not in scope during type checking, but it passed the renamer","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[13738],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule Bug where\r\n\r\nimport Data.Proxy\r\n\r\ndata family Fam\r\ndata instance Fam = MkFam (forall (a :: k). Proxy a)\r\n}}}\r\n\r\nOn GHC 8.0.1, 8.0.2, 8.2.1, and HEAD, this fails with a GHC internal error:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Bug.hs\r\nGHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:9:41: error:\r\n • GHC internal error: ‘k’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [r1vy :-> APromotionErr FamDataConPE]\r\n • In the kind ‘k’\r\n In the type ‘(forall (a :: k). Proxy a)’\r\n In the definition of data constructor ‘MkFam’\r\n |\r\n9 | data instance Fam = MkFam (forall (a :: k). Proxy a)\r\n | ^\r\n}}}\r\n\r\nThis is a regression, since on GHC 7.10.3, it did not crash:\r\n\r\n{{{\r\n$ /opt/ghc/7.10.3/bin/ghci Bug.hs\r\nGHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:9:21:\r\n Data constructor ‘MkFam’ has existential type variables, a context, or a specialised result type\r\n MkFam :: forall (k :: BOX).\r\n (forall (k :: BOX) (a :: k). Proxy a) -> Fam\r\n (Use ExistentialQuantification or GADTs to allow this)\r\n In the definition of data constructor ‘MkFam’\r\n In the data instance declaration for ‘Fam’\r\n}}}\r\n\r\nThis smells like #13738, but no `TypeApplications` are involved here, so I decided to open a separate ticket to be safe.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13983Type synonym referred to as datatype in error message2019-07-07T18:19:02ZRyan ScottType synonym referred to as datatype in error messageTo reproduce the issue, compile this file with GHC 8.0.1, 8.0.2, 8.2.1, or HEAD:
```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
module Bug where
import Data.Proxy
type Wat = forall (a :: k). Proxy a
```
```
GHCi, versio...To reproduce the issue, compile this file with GHC 8.0.1, 8.0.2, 8.2.1, or HEAD:
```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
module Bug where
import Data.Proxy
type Wat = forall (a :: k). Proxy a
```
```
GHCi, version 8.3.20170706: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:7:1: error:
• Kind variable ‘k’ is implicitly bound in datatype
‘Wat’, but does not appear as the kind of any
of its type variables. Perhaps you meant
to bind it (with TypeInType) explicitly somewhere?
Type variables with inferred kinds: (k :: *)
• In the type declaration for ‘Wat’
|
7 | type Wat = forall (a :: k). Proxy a
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
The error message mistakenly refers to `Wat` as a datatype.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1 |
| 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":"Type synonym referred to as datatype in error message","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"To reproduce the issue, compile this file with GHC 8.0.1, 8.0.2, 8.2.1, or HEAD:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE RankNTypes #-}\r\nmodule Bug where\r\n\r\nimport Data.Proxy\r\n\r\ntype Wat = forall (a :: k). Proxy a\r\n}}}\r\n\r\n{{{\r\nGHCi, version 8.3.20170706: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:7:1: error:\r\n • Kind variable ‘k’ is implicitly bound in datatype\r\n ‘Wat’, but does not appear as the kind of any\r\n of its type variables. Perhaps you meant\r\n to bind it (with TypeInType) explicitly somewhere?\r\n Type variables with inferred kinds: (k :: *)\r\n • In the type declaration for ‘Wat’\r\n |\r\n7 | type Wat = forall (a :: k). Proxy a\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nThe error message mistakenly refers to `Wat` as a datatype.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13972GHC 8.2 error message around indexes for associated type instances is baffling2019-07-07T18:19:06ZRyan ScottGHC 8.2 error message around indexes for associated type instances is bafflingThis program doesn't typecheck (only in GHC 8.2 and later):
```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
class C (a :: k) where
type T k :: Type
instan...This program doesn't typecheck (only in GHC 8.2 and later):
```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
class C (a :: k) where
type T k :: Type
instance C Left where
type T (a -> Either a b) = Int
```
```
$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:12:8: error:
• Type indexes must match class instance head
Expected: T (a -> Either a b)
Actual: T (a -> Either a b)
• In the type instance declaration for ‘T’
In the instance declaration for ‘C Left’
|
12 | type T (a -> Either a b) = Int
| ^^^^^^^^^^^^^^^^^^^^^^^^^
```
Well those expected and actual types look pretty darn similar to me!
Note that the problem can be worked around by giving an explicit kind annotation for `Left`:
```hs
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
class C (a :: k) where
type T k :: Type
instance C (Left :: a -> Either a b) where
type T (a -> Either a b) = Int
```
I see two things we could do here:
1. Relax the "Type indexes must match class instance head" check so that it doesn't apply to invisible kind variables like `a` and `b`.
1. Clarify the error message. At the very least, we could say `Expected: T (a1 -> Either a1 b1)` as a hint that `a` and `b` aren't the same type variables as `a1` and `b1`. In an ideal world, we'd even indicate where `a1` and `b1` should be coming from (the kind of `Left`).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.2.1-rc2 |
| 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":"GHC 8.2 error message around indexes for associated type instances is baffling","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.1-rc2","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program doesn't typecheck (only in GHC 8.2 and later):\r\n\r\n{{{#!hs\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass C (a :: k) where\r\n type T k :: Type\r\n\r\ninstance C Left where\r\n type T (a -> Either a b) = Int\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Bug.hs\r\nGHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:12:8: error:\r\n • Type indexes must match class instance head\r\n Expected: T (a -> Either a b)\r\n Actual: T (a -> Either a b)\r\n • In the type instance declaration for ‘T’\r\n In the instance declaration for ‘C Left’\r\n |\r\n12 | type T (a -> Either a b) = Int\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nWell those expected and actual types look pretty darn similar to me!\r\n\r\nNote that the problem can be worked around by giving an explicit kind annotation for `Left`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass C (a :: k) where\r\n type T k :: Type\r\n\r\ninstance C (Left :: a -> Either a b) where\r\n type T (a -> Either a b) = Int\r\n}}}\r\n\r\nI see two things we could do here:\r\n\r\n1. Relax the \"Type indexes must match class instance head\" check so that it doesn't apply to invisible kind variables like `a` and `b`.\r\n2. Clarify the error message. At the very least, we could say `Expected: T (a1 -> Either a1 b1)` as a hint that `a` and `b` aren't the same type variables as `a1` and `b1`. In an ideal world, we'd even indicate where `a1` and `b1` should be coming from (the kind of `Left`).","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13968TH gives "Illegal binding of built-in syntax" error2022-05-23T06:28:37ZRyan ScottTH gives "Illegal binding of built-in syntax" errorIf you try to splice in a definition that borrows an already existing `Name` using Template Haskell, GHC gives a confusing error message:
```hs
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Language.Haskell.TH
$(pure [ValD ...If you try to splice in a definition that borrows an already existing `Name` using Template Haskell, GHC gives a confusing error message:
```hs
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Language.Haskell.TH
$(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []])
```
```
$ /opt/ghc/8.2.1/bin/runghc Bug.hs
Bug.hs:6:3: error: Illegal binding of built-in syntax: succ
|
6 | $(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
I'm not exactly sure what should happen here. My hunch was that my spliced-in `succ` would shadow the `succ` that's already in-scope. But in any case, the error message you get currently is quite awful, so at the very least that should be improved.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"TH gives \"Illegal binding of built-in syntax\" error","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If you try to splice in a definition that borrows an already existing `Name` using Template Haskell, GHC gives a confusing error message:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\nmodule Bug where\r\n\r\nimport Language.Haskell.TH\r\n\r\n$(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []])\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/runghc Bug.hs\r\n\r\nBug.hs:6:3: error: Illegal binding of built-in syntax: succ\r\n |\r\n6 | $(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []])\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nI'm not exactly sure what should happen here. My hunch was that my spliced-in `succ` would shadow the `succ` that's already in-scope. But in any case, the error message you get currently is quite awful, so at the very least that should be improved.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13963Runtime representation confusingly displayed2019-07-07T18:19:09ZIcelandjackRuntime representation confusingly displayed1. 3.20170605:
```
> :set -XRankNTypes -XTypeInType
> import GHC.Exts (TYPE, RuntimeRep(LiftedRep))
> type Pair (a::TYPE rep) (b::TYPE rep') rep'' = forall (r::TYPE rep''). (a -> b -> r) -> r
> :kind Pair
Pair :: * -> * -> *
> :kind Pa...1. 3.20170605:
```
> :set -XRankNTypes -XTypeInType
> import GHC.Exts (TYPE, RuntimeRep(LiftedRep))
> type Pair (a::TYPE rep) (b::TYPE rep') rep'' = forall (r::TYPE rep''). (a -> b -> r) -> r
> :kind Pair
Pair :: * -> * -> *
> :kind Pair Int
Pair Int :: * -> *
> :kind Pair Int Float
Pair Int Float :: *
> :kind Pair Int Float LiftedRep
Pair Int Float LiftedRep :: *
```
It still behaves oddly with `-fprint-explicit-runtime-reps` enabled
```
> :set -fprint-explicit-runtime-reps
> :kind Pair
Pair :: * -> * -> forall (rep'' :: RuntimeRep) -> *
> :kind Pair Int
Pair Int :: * -> forall (rep'' :: RuntimeRep) -> *
> :kind Pair Int Float
Pair Int Float :: *
> :kind Pair Int Float LiftedRep
Pair Int Float LiftedRep :: *
```
I would have also expected to see `Pair`'s kind displayed something like this
```hs
forall {rep :: RuntimeRep} {rep' :: RuntimeRep}. TYPE rep -> TYPE rep' -> forall (rep'' :: RuntimeRep) -> *
```
which is how the kind of the corresponding `newtype` gets displayed
```
> newtype Pair2 (a::TYPE rep) (b::TYPE rep') rep'' = P2 (forall (r::TYPE rep''). (a -> b -> r) -> r)
> :kind Pair2
Pair2 :: forall {rep :: RuntimeRep} {rep' :: RuntimeRep}.
TYPE rep -> TYPE rep' -> forall (rep'' :: RuntimeRep) -> *
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.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":"Runtime representation confusingly displayed","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"8.3.20170605:\r\n\r\n{{{\r\n> :set -XRankNTypes -XTypeInType \r\n> import GHC.Exts (TYPE, RuntimeRep(LiftedRep))\r\n> type Pair (a::TYPE rep) (b::TYPE rep') rep'' = forall (r::TYPE rep''). (a -> b -> r) -> r\r\n> :kind Pair\r\nPair :: * -> * -> *\r\n> :kind Pair Int\r\nPair Int :: * -> *\r\n> :kind Pair Int Float\r\nPair Int Float :: *\r\n> :kind Pair Int Float LiftedRep\r\nPair Int Float LiftedRep :: *\r\n}}}\r\n\r\nIt still behaves oddly with `-fprint-explicit-runtime-reps` enabled\r\n\r\n{{{\r\n> :set -fprint-explicit-runtime-reps \r\n> :kind Pair\r\nPair :: * -> * -> forall (rep'' :: RuntimeRep) -> *\r\n> :kind Pair Int\r\nPair Int :: * -> forall (rep'' :: RuntimeRep) -> *\r\n> :kind Pair Int Float\r\nPair Int Float :: *\r\n> :kind Pair Int Float LiftedRep \r\nPair Int Float LiftedRep :: *\r\n}}}\r\n\r\nI would have also expected to see `Pair`'s kind displayed something like this\r\n\r\n{{{#!hs\r\nforall {rep :: RuntimeRep} {rep' :: RuntimeRep}. TYPE rep -> TYPE rep' -> forall (rep'' :: RuntimeRep) -> *\r\n}}}\r\n\r\nwhich is how the kind of the corresponding `newtype` gets displayed \r\n\r\n{{{\r\n> newtype Pair2 (a::TYPE rep) (b::TYPE rep') rep'' = P2 (forall (r::TYPE rep''). (a -> b -> r) -> r)\r\n> :kind Pair2\r\nPair2 :: forall {rep :: RuntimeRep} {rep' :: RuntimeRep}.\r\n TYPE rep -> TYPE rep' -> forall (rep'' :: RuntimeRep) -> *\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13949Haddock fails to typecheck an example with TemplateHaskell2019-07-07T18:19:16ZDouglas Wilsondouglas@well-typed.comHaddock fails to typecheck an example with TemplateHaskellReported by leftaroundabout at [https://github.com/haskell/haddock/issues/650](https://github.com/haskell/haddock/issues/650). Surely this is a bug in GhcMake.enableCodegenForTH introduced in 53c78be0aab76a3107c4dacbb1d177afacdd37fa.
<d...Reported by leftaroundabout at [https://github.com/haskell/haddock/issues/650](https://github.com/haskell/haddock/issues/650). Surely this is a bug in GhcMake.enableCodegenForTH introduced in 53c78be0aab76a3107c4dacbb1d177afacdd37fa.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.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":"Haddock fails to typecheck an example with TemplateHaskell","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Reported by leftaroundabout at [https://github.com/haskell/haddock/issues/650]. Surely this is a bug in GhcMake.enableCodegenForTH introduced in 53c78be0aab76a3107c4dacbb1d177afacdd37fa.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1Douglas Wilsondouglas@well-typed.comDouglas Wilsondouglas@well-typed.comhttps://gitlab.haskell.org/ghc/ghc/-/issues/13919Incorrect unused top binding warning when interacting with GHC.Generics2020-06-05T12:17:56ZTanebIncorrect unused top binding warning when interacting with GHC.GenericsThe program
```hs
{-# LANGUAGE DeriveGeneric #-}
module Main (main) where
import Data.Aeson
import GHC.Generics
data Foo = Foo {bar :: String} deriving Generic
instance ToJSON Foo where
toJSON = genericToJSON defaultOptions
main :...The program
```hs
{-# LANGUAGE DeriveGeneric #-}
module Main (main) where
import Data.Aeson
import GHC.Generics
data Foo = Foo {bar :: String} deriving Generic
instance ToJSON Foo where
toJSON = genericToJSON defaultOptions
main :: IO ()
main = print (toJSON (Foo "hello"))
```
emits the warning
```
UTB.hs:7:17: warning: [-Wunused-top-binds]
Defined but not used: ‘bar’
```
but removing that binding changes the behaviour of the program, as the above prints
```
Object (fromList [("bar",String "hello")])
```
but
```hs
{-# LANGUAGE DeriveGeneric #-}
module Main (main) where
import Data.Aeson
import GHC.Generics
data Foo = Foo String deriving Generic
instance ToJSON Foo where
toJSON = genericToJSON defaultOptions
main :: IO ()
main = print (toJSON (Foo "hello"))
```
prints
```
String "hello"
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.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":"Incorrect unused top binding warning when interacting with GHC.Generics","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The program\r\n{{{#!hs\r\n{-# LANGUAGE DeriveGeneric #-}\r\nmodule Main (main) where\r\n\r\nimport Data.Aeson\r\nimport GHC.Generics\r\n\r\ndata Foo = Foo {bar :: String} deriving Generic\r\n\r\ninstance ToJSON Foo where\r\n toJSON = genericToJSON defaultOptions\r\n\r\nmain :: IO ()\r\nmain = print (toJSON (Foo \"hello\"))\r\n}}}\r\n\r\nemits the warning\r\n\r\n{{{\r\nUTB.hs:7:17: warning: [-Wunused-top-binds]\r\n Defined but not used: ‘bar’\r\n}}}\r\n\r\nbut removing that binding changes the behaviour of the program, as the above prints\r\n\r\n{{{\r\nObject (fromList [(\"bar\",String \"hello\")])\r\n}}}\r\n\r\nbut\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveGeneric #-}\r\nmodule Main (main) where\r\n\r\nimport Data.Aeson\r\nimport GHC.Generics\r\n\r\ndata Foo = Foo String deriving Generic\r\n\r\ninstance ToJSON Foo where\r\n toJSON = genericToJSON defaultOptions\r\n\r\nmain :: IO ()\r\nmain = print (toJSON (Foo \"hello\"))\r\n}}}\r\n\r\nprints\r\n\r\n{{{\r\nString \"hello\"\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13914-fignore-asserts flag not handled by recompilation checker2019-07-07T18:19:30ZÖmer Sinan Ağacan-fignore-asserts flag not handled by recompilation checkerAs demonstrated below, `-fignore-asserts` is not stored in .hi files and not
checked by recompilation checker.
```
$ cat main.hs
module Main where
import Control.Exception
main = do
assert False (putStrLn "OK")
$ ghc main.hs
[1 of...As demonstrated below, `-fignore-asserts` is not stored in .hi files and not
checked by recompilation checker.
```
$ cat main.hs
module Main where
import Control.Exception
main = do
assert False (putStrLn "OK")
$ ghc main.hs
[1 of 1] Compiling Main ( main.hs, main.o )
Linking main ...
$ ./main
main: Assertion failed
CallStack (from HasCallStack):
assert, called at main.hs:6:5 in main:Main
$ ghc main.hs -fignore-asserts
$ ./main
main: Assertion failed
CallStack (from HasCallStack):
assert, called at main.hs:6:5 in main:Main
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Driver |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"-fignore-asserts flag not handled by recompilation checker","status":"New","operating_system":"","component":"Driver","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"As demonstrated below, `-fignore-asserts` is not stored in .hi files and not\r\nchecked by recompilation checker.\r\n\r\n{{{\r\n$ cat main.hs\r\nmodule Main where\r\n\r\nimport Control.Exception\r\n\r\nmain = do\r\n assert False (putStrLn \"OK\")\r\n$ ghc main.hs\r\n[1 of 1] Compiling Main ( main.hs, main.o )\r\nLinking main ...\r\n$ ./main\r\nmain: Assertion failed\r\nCallStack (from HasCallStack):\r\n assert, called at main.hs:6:5 in main:Main\r\n$ ghc main.hs -fignore-asserts\r\n$ ./main\r\nmain: Assertion failed\r\nCallStack (from HasCallStack):\r\n assert, called at main.hs:6:5 in main:Main\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13911GHC RTS VEH swallowing exceptions2019-07-07T18:19:31Ztim-m89GHC RTS VEH swallowing exceptionsOn ticket #6079, a top level VEH handler was implemented which effectively means there is no uncaught exceptions for those it catches.
#13108 improved things a little by giving some basic info upon segfaults, but otherwise left everythi...On ticket #6079, a top level VEH handler was implemented which effectively means there is no uncaught exceptions for those it catches.
#13108 improved things a little by giving some basic info upon segfaults, but otherwise left everything as is.
Rather than trying to catch all exceptions, I think it would be more worthwhile to leave them uncaught, and let current & future tools have an eyes open approach to debugging.
If something needs to go in the place of the global handler, perhaps SetUnhandledExceptionFilter is of use?
VEH overrides all other exception handlers as far as I'm aware (C++, SEH, .NET), so trying to interop with any other code that wants to handle it's own exceptions won't work unless said code is also using VEH.
This is causing an issue for some code I've been working on, and I've documented similar to this bug report there also: https://gitlab.com/tim-m89/clr-haskell/issues/25\#note_33960203
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | RuntimeCrash |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"GHC RTS VEH swallowing exceptions","status":"New","operating_system":"","component":"Runtime System","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"On ticket #6079, a top level VEH handler was implemented which effectively means there is no uncaught exceptions for those it catches.\r\n\r\n#13108 improved things a little by giving some basic info upon segfaults, but otherwise left everything as is. \r\n\r\nRather than trying to catch all exceptions, I think it would be more worthwhile to leave them uncaught, and let current & future tools have an eyes open approach to debugging.\r\n\r\nIf something needs to go in the place of the global handler, perhaps SetUnhandledExceptionFilter is of use?\r\n\r\nVEH overrides all other exception handlers as far as I'm aware (C++, SEH, .NET), so trying to interop with any other code that wants to handle it's own exceptions won't work unless said code is also using VEH.\r\n\r\nThis is causing an issue for some code I've been working on, and I've documented similar to this bug report there also: https://gitlab.com/tim-m89/clr-haskell/issues/25#note_33960203\r\n","type_of_failure":"RuntimeCrash","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13909Misleading error message when partially applying a data type with a visible q...2019-07-07T18:19:32ZRyan ScottMisleading error message when partially applying a data type with a visible quantifier in its kindI'm not sure if this is a bug or an intended design, so I'll ask here. I want this program to typecheck:
```hs
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
data Hm (k :: Type) (a :: k) :: Type
class HasName (a :: k) ...I'm not sure if this is a bug or an intended design, so I'll ask here. I want this program to typecheck:
```hs
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
data Hm (k :: Type) (a :: k) :: Type
class HasName (a :: k) where
getName :: proxy a -> String
instance HasName Hm where
getName _ = "Hm"
```
This is rejected, however:
```
$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.0.20170623: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/ryanglscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:11:18: error:
• Expecting two more arguments to ‘Hm’
Expected kind ‘k0’, but ‘Hm’ has kind ‘forall k -> k -> *’
• In the first argument of ‘HasName’, namely ‘Hm’
In the instance declaration for ‘HasName Hm’
|
11 | instance HasName Hm where
| ^^
```
The culprit appears to be the fact that `Hm` has kind `forall k -> k -> *`, which uses a visible quantifier. Does this prevent partial applications of `Hm`? Or is this simply a GHC bug?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1 |
| 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":"Can't partially apply a data type with a visible quantifier in its kind","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I'm not sure if this is a bug or an intended design, so I'll ask here. I want this program to typecheck:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TypeInType #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata Hm (k :: Type) (a :: k) :: Type\r\n\r\nclass HasName (a :: k) where\r\n getName :: proxy a -> String\r\n\r\ninstance HasName Hm where\r\n getName _ = \"Hm\"\r\n}}}\r\n\r\nThis is rejected, however:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Bug.hs\r\nGHCi, version 8.2.0.20170623: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/ryanglscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:11:18: error:\r\n • Expecting two more arguments to ‘Hm’\r\n Expected kind ‘k0’, but ‘Hm’ has kind ‘forall k -> k -> *’\r\n • In the first argument of ‘HasName’, namely ‘Hm’\r\n In the instance declaration for ‘HasName Hm’\r\n |\r\n11 | instance HasName Hm where\r\n | ^^\r\n}}}\r\n\r\nThe culprit appears to be the fact that `Hm` has kind `forall k -> k -> *`, which uses a visible quantifier. Does this prevent partial applications of `Hm`? Or is this simply a GHC bug?","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13908sameMutableArray equivalent for Array2023-02-14T11:40:53ZwintersameMutableArray equivalent for ArraySometime it is useful to compare reference equality for immutable arrays, for example when comparing vectors which are slices of arrays, we may want to know if two vectors are slices of the same array. But currently we only have `sameMut...Sometime it is useful to compare reference equality for immutable arrays, for example when comparing vectors which are slices of arrays, we may want to know if two vectors are slices of the same array. But currently we only have `sameMutableXXXArray` primitives.
A workaround may look like this:
```hs
sameArray :: Array a -> Array a -> Bool
sameArray arr1 arr2 = runST (do
marr1 <- unsafeThawArray arr1
marr2 <- unsafeThawArray arr2
return (sameMutableArray marr1 marr2)
)
```
But the problem is for boxed arrays, this code will push an unchanged array to mutable list if it's already on older generations. Next GC will have to scan it(at least will scan its card table).
I can see two solutions here, first one is to add `sameXXXArray` for all array types. The second one is somehow more complex:
Currently we simply rewrite array's header to `MUT_ARR_PTRS_FROZEN0/SMALL_MUT_ARR_PTRS_FROZEN0` when we do `unsafeFreeze`. But for mutable array with no write happend, e.g. the ones with `MUT_ARR_PTRS_CLEAN/SMALL_MUT_ARR_PTRS_CLEAN` header. we can safely rewrite the header to `MUT_ARR_PTRS_FROZEN/SMALL_MUT_ARR_PTRS_FROZEN`, so that we can keep it from next GC.
Then to fix previous code, we can add a freeze before returning.
Of course we can do these two solutions all together ; )8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13903KQueue evtmgr backend fails to register for write events2022-02-11T15:58:15ZwaldheinzKQueue evtmgr backend fails to register for write eventsThe root of the problem is that the `GHC.Event.KQueue.toFilter` function has type `GHC.Event.Internal.Event -> Filter` with GHC's `Event` being a bitmask which can represent read events, write events or a combination of those.
It happen...The root of the problem is that the `GHC.Event.KQueue.toFilter` function has type `GHC.Event.Internal.Event -> Filter` with GHC's `Event` being a bitmask which can represent read events, write events or a combination of those.
It happens that the event manager requests it's backend to be notified about read *and* write events on some fd, and because the kqueue `EVFILT_*`s are *not* bitmasks, the above function cannot capture this, silently dropping the desire to be notified about write events.
The following program triggers the problematic behaviour:
```
import Control.Concurrent ( forkIO, killThread )
import Control.Exception ( finally )
import Control.Monad.Trans.Resource ( runResourceT )
import Control.Monad.IO.Class ( liftIO )
import qualified Data.ByteString as BS
import Data.Conduit ( ($$), ($=) )
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.List as CL
import qualified Data.Conduit.Network as CN
import Data.IORef ( newIORef, modifyIORef', readIORef)
main :: IO ()
main = CN.runTCPClient (CN.clientSettings 5555 "192.168.2.11") client
where
logMsg cnt = CL.mapM $ \bs -> liftIO $ do
modifyIORef' cnt (+ 1)
readIORef cnt >>= \x -> putStrLn $
"msg #" ++ show x ++ " of size: " ++ show (BS.length bs)
return bs
client ad = do
reader <- forkIO (runResourceT $ CN.appSource ad
$$ CL.mapM_ ( \bs -> (liftIO . putStrLn) $
"read " ++ show (BS.length bs) ++ " bytes"))
cnt <- newIORef ( 0 :: Int )
let
runPipe = runResourceT $ CB.sourceFile "cool-linux-distro.iso"
$$ logMsg cnt
$= CN.appSink ad
runPipe `finally` (killThread reader)
```
Having a `nc -l -p 5555 > /dev/null` running on another machine is sufficient to sink the data.
Assuming that we can read `bigfile.iso` faster than we can send out over the socket, the `send` syscall will at some point give an `EAGAIN` as can be seen in the `truss` output:
```
write(1,"msg #20 of size: 32752\n",23) = 23 (0x17)
sendto(12,"\f\2409\0\M^RA\^T\M-&A\M-'\M-d8"...,32752,0x0,NULL,0x0) = 32752 (0x7ff0)
read(13,"\M^?\0'\\\M-B\M-:+\^]D\M-0\M-="...,32752) = 32752 (0x7ff0)
poll({ 1/POLLOUT },1,0) = 1 (0x1)
msg #21 of size: 32752
write(1,"msg #21 of size: 32752\n",23) = 23 (0x17)
sendto(12,"\M^?\0'\\\M-B\M-:+\^]D\M-0\M-="...,32752,0x0,NULL,0x0) = 19204 (0x4b04)
sendto(12,"\M-j$2\M^BH\M-#-\^A\M-E\^O\M^Y\a"...,13548,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable'
SIGNAL 26 (SIGVTALRM)
sigprocmask(SIG_SETMASK,{ SIGVTALRM },0x0) = 0 (0x0)
sigreturn(0x7fffffff9c60) ERR#35 'Resource temporarily unavailable'
kevent(3,{ 12,EVFILT_READ,EV_ADD|EV_ONESHOT,0x0,0x0,0x0 },1,0x0,0,{ 0.000000000 }) = 0 (0x0)
_umtx_op(0x800c71ed0,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) ERR#4 'Interrupted system call'
SIGNAL 26 (SIGVTALRM)
sigprocmask(SIG_SETMASK,{ SIGVTALRM },0x0) = 0 (0x0)
sigreturn(0x7fffffffdc00) ERR#4 'Interrupted system call'
_umtx_op(0x800c71ed0,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) ERR#4 'Interrupted system call'
SIGNAL 26 (SIGVTALRM)
```
Not the `sendto` call on fd 12 resulting in `ERR#35`, soon followed by an `kevent` call for that same fd and only `EVFILT_READ` set. This makes little sense as it was an attempt to *write* that just failed. This is caused by `toFilter` giving precedence to `read` events, dropping the write event. Not starting the `reader` thread prevents bad things from happening as then the `write` events are properly passed thru to kqueue.
I have an initial version of a patch fixing this.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"KQueue evtmgr backend fails to register for write events","status":"New","operating_system":"","component":"Runtime System","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The root of the problem is that the `GHC.Event.KQueue.toFilter` function has type `GHC.Event.Internal.Event -> Filter` with GHC's `Event` being a bitmask which can represent read events, write events or a combination of those.\r\n\r\nIt happens that the event manager requests it's backend to be notified about read ''and'' write events on some fd, and because the kqueue `EVFILT_*`s are ''not'' bitmasks, the above function cannot capture this, silently dropping the desire to be notified about write events.\r\n\r\nThe following program triggers the problematic behaviour:\r\n\r\n{{{\r\n\r\nimport Control.Concurrent ( forkIO, killThread )\r\nimport Control.Exception ( finally )\r\nimport Control.Monad.Trans.Resource ( runResourceT )\r\nimport Control.Monad.IO.Class ( liftIO )\r\nimport qualified Data.ByteString as BS\r\nimport Data.Conduit ( ($$), ($=) )\r\nimport qualified Data.Conduit.Binary as CB\r\nimport qualified Data.Conduit.List as CL\r\nimport qualified Data.Conduit.Network as CN\r\nimport Data.IORef ( newIORef, modifyIORef', readIORef)\r\n\r\nmain :: IO ()\r\nmain = CN.runTCPClient (CN.clientSettings 5555 \"192.168.2.11\") client\r\n where\r\n logMsg cnt = CL.mapM $ \\bs -> liftIO $ do\r\n modifyIORef' cnt (+ 1)\r\n readIORef cnt >>= \\x -> putStrLn $\r\n \"msg #\" ++ show x ++ \" of size: \" ++ show (BS.length bs)\r\n return bs\r\n\r\n client ad = do\r\n reader <- forkIO (runResourceT $ CN.appSource ad\r\n $$ CL.mapM_ ( \\bs -> (liftIO . putStrLn) $\r\n \"read \" ++ show (BS.length bs) ++ \" bytes\"))\r\n cnt <- newIORef ( 0 :: Int )\r\n\r\n let\r\n runPipe = runResourceT $ CB.sourceFile \"cool-linux-distro.iso\"\r\n $$ logMsg cnt\r\n $= CN.appSink ad\r\n\r\n runPipe `finally` (killThread reader)\r\n}}}\r\n\r\nHaving a `nc -l -p 5555 > /dev/null` running on another machine is sufficient to sink the data.\r\n\r\nAssuming that we can read `bigfile.iso` faster than we can send out over the socket, the `send` syscall will at some point give an `EAGAIN` as can be seen in the `truss` output:\r\n\r\n{{{\r\nwrite(1,\"msg #20 of size: 32752\\n\",23) = 23 (0x17)\r\nsendto(12,\"\\f\\2409\\0\\M^RA\\^T\\M-&A\\M-'\\M-d8\"...,32752,0x0,NULL,0x0) = 32752 (0x7ff0)\r\nread(13,\"\\M^?\\0'\\\\\\M-B\\M-:+\\^]D\\M-0\\M-=\"...,32752) = 32752 (0x7ff0)\r\npoll({ 1/POLLOUT },1,0) = 1 (0x1)\r\nmsg #21 of size: 32752\r\nwrite(1,\"msg #21 of size: 32752\\n\",23) = 23 (0x17)\r\nsendto(12,\"\\M^?\\0'\\\\\\M-B\\M-:+\\^]D\\M-0\\M-=\"...,32752,0x0,NULL,0x0) = 19204 (0x4b04)\r\nsendto(12,\"\\M-j$2\\M^BH\\M-#-\\^A\\M-E\\^O\\M^Y\\a\"...,13548,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable'\r\nSIGNAL 26 (SIGVTALRM)\r\nsigprocmask(SIG_SETMASK,{ SIGVTALRM },0x0) = 0 (0x0)\r\nsigreturn(0x7fffffff9c60) ERR#35 'Resource temporarily unavailable'\r\nkevent(3,{ 12,EVFILT_READ,EV_ADD|EV_ONESHOT,0x0,0x0,0x0 },1,0x0,0,{ 0.000000000 }) = 0 (0x0)\r\n_umtx_op(0x800c71ed0,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) ERR#4 'Interrupted system call'\r\nSIGNAL 26 (SIGVTALRM)\r\nsigprocmask(SIG_SETMASK,{ SIGVTALRM },0x0) = 0 (0x0)\r\nsigreturn(0x7fffffffdc00) ERR#4 'Interrupted system call'\r\n_umtx_op(0x800c71ed0,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) ERR#4 'Interrupted system call'\r\nSIGNAL 26 (SIGVTALRM)\r\n}}}\r\n\r\nNot the `sendto` call on fd 12 resulting in `ERR#35`, soon followed by an `kevent` call for that same fd and only `EVFILT_READ` set. This makes little sense as it was an attempt to ''write'' that just failed. This is caused by `toFilter` giving precedence to `read` events, dropping the write event. Not starting the `reader` thread prevents bad things from happening as then the `write` events are properly passed thru to kqueue.\r\n\r\nI have an initial version of a patch fixing this.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13902Misleading function arity mismatch error with TypeApplications2019-07-07T18:19:34ZRyan ScottMisleading function arity mismatch error with TypeApplications```hs
{-# LANGUAGE TypeApplications #-}
f :: a -> a
f x = x
g :: Int
g = f @Int 42 5
```
```
GHCi, version 8.3.20170614: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Ma...```hs
{-# LANGUAGE TypeApplications #-}
f :: a -> a
f x = x
g :: Int
g = f @Int 42 5
```
```
GHCi, version 8.3.20170614: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Main ( Bug.hs, interpreted )
Bug.hs:7:5: error:
• Couldn't match expected type ‘Integer -> Int’
with actual type ‘Int’
• The function ‘f’ is applied to three arguments,
but its type ‘Int -> Int’ has only one
In the expression: f @Int 42 5
In an equation for ‘g’: g = f @Int 42 5
|
7 | g = f @Int 42 5
| ^^^^^^^^^^^
```
That error message is quite confusing to read, since it reports that:
- `f` is applied to three arguments, which //includes// a visible type application
- `f` only has one argument, which //excludes// the visible type application
We ought to be able to do better. My suggestion would be to report this instead:
```
• The expression ‘f @Int’ is applied to two arguments,
but its type ‘Int -> Int’ has only one
In the expression: f @Int 42 5
In an equation for ‘g’: g = f @Int 42 5
```
Although I'm sure there are other ways the same information could be conveyed (e.g., `The function ‘f’ is applied to two value arguments`).8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13885Template Haskell doesn't freshen GADT type variables properly2023-02-05T14:13:33ZRyan ScottTemplate Haskell doesn't freshen GADT type variables properlyA simple way to illustrate this bug is with this code:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Foo where
import qualified Data.Type.Equality as DTE ...A simple way to illustrate this bug is with this code:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Foo where
import qualified Data.Type.Equality as DTE ((:~:))
import Language.Haskell.TH
data a :~: b where
Refl :: a :~: a
$(return [])
main :: IO ()
main = do
putStrLn "Imported\n-----"
putStrLn $(reify ''(DTE.:~:) >>= stringE . pprint)
putStrLn "-----\n\nLocally defined\n-----"
putStrLn $(reify ''(:~:) >>= stringE . pprint)
putStrLn "-----"
```
Here, I'm pretty-printing the reified Template Haskell information about two datatypes: one that is imported from another package (`base`), and another that is defined locally. Aside from their definition sites, they are otherwise identical. However, when reifying them with Template Haskell, there is another distinction one can observe:
```
$ /opt/ghc/8.2.1/bin/runghc Foo.hs
Imported
-----
data Data.Type.Equality.:~: (a_0 :: k_1) (b_2 :: k_1) where
Data.Type.Equality.Refl :: forall (k_1 :: *) (a_0 :: k_1) . Data.Type.Equality.:~: a_0
a_0
-----
Locally defined
-----
data Foo.:~: (a_0 :: k_1) (b_2 :: k_1) where
Foo.Refl :: forall (k_3 :: *) (a_4 :: k_3) . Foo.:~: a_4 a_4
-----
```
The locally defined information looks fine, but the one imported from `base` is suspicious. Namely, the `k_1` variable is used both in the datatype head and in the quantified variables for the constructor! To confirm this, you can print out more verbose info with `show` instead of `pprint`:
```
Imported
-----
TyConI (DataD [] Data.Type.Equality.:~: [KindedTV a_6989586621679026781 (VarT k_6989586621679026780),KindedTV b_6989586621679026782 (VarT k_6989586621679026780)] Nothing [ForallC [KindedTV k_6989586621679026780 StarT,KindedTV a_6989586621679026781 (VarT k_6989586621679026780)] [] (GadtC [Data.Type.Equality.Refl] [] (AppT (AppT (ConT Data.Type.Equality.:~:) (VarT a_6989586621679026781)) (VarT a_6989586621679026781)))] [])
-----
Locally defined
-----
TyConI (DataD [] Foo.:~: [KindedTV a_6989586621679016094 (VarT k_6989586621679016098),KindedTV b_6989586621679016095 (VarT k_6989586621679016098)] Nothing [ForallC [KindedTV k_6989586621679016108 StarT,KindedTV a_6989586621679016096 (VarT k_6989586621679016108)] [] (GadtC [Foo.Refl] [] (AppT (AppT (ConT Foo.:~:) (VarT a_6989586621679016096)) (VarT a_6989586621679016096)))] [])
-----
```
Sure enough, the variable `k_6989586621679026780` is used in both places. I would expect this not to happen, since the two sets of variables are scoped differently, and in practice, I have to work around this by freshening the type variables for the constructor, which is annoying.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Template Haskell doesn't freshen GADT kind variables properly when imported from another package","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"A simple way to illustrate this bug is with this code:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Foo where\r\n\r\nimport qualified Data.Type.Equality as DTE ((:~:))\r\nimport Language.Haskell.TH\r\n\r\ndata a :~: b where\r\n Refl :: a :~: a\r\n\r\n$(return [])\r\n\r\nmain :: IO ()\r\nmain = do\r\n putStrLn \"Imported\\n-----\"\r\n putStrLn $(reify ''(DTE.:~:) >>= stringE . pprint)\r\n putStrLn \"-----\\n\\nLocally defined\\n-----\"\r\n putStrLn $(reify ''(:~:) >>= stringE . pprint)\r\n putStrLn \"-----\"\r\n}}}\r\n\r\nHere, I'm pretty-printing the reified Template Haskell information about two datatypes: one that is imported from another package (`base`), and another that is defined locally. Aside from their definition sites, they are otherwise identical. However, when reifying them with Template Haskell, there is another distinction one can observe:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/runghc Foo.hs\r\nImported\r\n-----\r\ndata Data.Type.Equality.:~: (a_0 :: k_1) (b_2 :: k_1) where\r\n Data.Type.Equality.Refl :: forall (k_1 :: *) (a_0 :: k_1) . Data.Type.Equality.:~: a_0\r\n a_0\r\n-----\r\n\r\nLocally defined\r\n-----\r\ndata Foo.:~: (a_0 :: k_1) (b_2 :: k_1) where\r\n Foo.Refl :: forall (k_3 :: *) (a_4 :: k_3) . Foo.:~: a_4 a_4\r\n-----\r\n}}}\r\n\r\nThe locally defined information looks fine, but the one imported from `base` is suspicious. Namely, the `k_1` variable is used both in the datatype head and in the quantified variables for the constructor! To confirm this, you can print out more verbose info with `show` instead of `pprint`:\r\n\r\n{{{\r\nImported\r\n-----\r\nTyConI (DataD [] Data.Type.Equality.:~: [KindedTV a_6989586621679026781 (VarT k_6989586621679026780),KindedTV b_6989586621679026782 (VarT k_6989586621679026780)] Nothing [ForallC [KindedTV k_6989586621679026780 StarT,KindedTV a_6989586621679026781 (VarT k_6989586621679026780)] [] (GadtC [Data.Type.Equality.Refl] [] (AppT (AppT (ConT Data.Type.Equality.:~:) (VarT a_6989586621679026781)) (VarT a_6989586621679026781)))] [])\r\n-----\r\n\r\nLocally defined\r\n-----\r\nTyConI (DataD [] Foo.:~: [KindedTV a_6989586621679016094 (VarT k_6989586621679016098),KindedTV b_6989586621679016095 (VarT k_6989586621679016098)] Nothing [ForallC [KindedTV k_6989586621679016108 StarT,KindedTV a_6989586621679016096 (VarT k_6989586621679016108)] [] (GadtC [Foo.Refl] [] (AppT (AppT (ConT Foo.:~:) (VarT a_6989586621679016096)) (VarT a_6989586621679016096)))] [])\r\n-----\r\n}}}\r\n\r\nSure enough, the variable `k_6989586621679026780` is used in both places. I would expect this not to happen, since the two sets of variables are scoped differently, and in practice, I have to work around this by freshening the type variables for the constructor, which is annoying.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13877GHC panic: No skolem info: k22019-07-07T18:19:42ZRyan ScottGHC panic: No skolem info: k2The following code causes a GHC panic on GHC 8.0.1, 8.0.2, 8.2.1, and HEAD:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables ...The following code causes a GHC panic on GHC 8.0.1, 8.0.2, 8.2.1, and HEAD:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Eliminator where
import Data.Kind
data family Sing (a :: k)
data instance Sing (z :: [a]) where
SNil :: Sing '[]
SCons :: Sing x -> Sing xs -> Sing (x:xs)
data TyFun :: * -> * -> *
type a ~> b = TyFun a b -> *
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
type a @@ b = Apply a b
infixl 9 @@
data FunArrow = (:->) | (:~>)
class FunType (arr :: FunArrow) where
type Fun (k1 :: Type) arr (k2 :: Type) :: Type
class FunType arr => AppType (arr :: FunArrow) where
type App k1 arr k2 (f :: Fun k1 arr k2) (x :: k1) :: k2
type FunApp arr = (FunType arr, AppType arr)
instance FunType (:->) where
type Fun k1 (:->) k2 = k1 -> k2
$(return []) -- This is only necessary for GHC 8.0 -- GHC 8.2 is smarter
instance AppType (:->) where
type App k1 (:->) k2 (f :: k1 -> k2) x = f x
instance FunType (:~>) where
type Fun k1 (:~>) k2 = k1 ~> k2
$(return [])
instance AppType (:~>) where
type App k1 (:~>) k2 (f :: k1 ~> k2) x = f @@ x
infixr 0 -?>
type (-?>) (k1 :: Type) (k2 :: Type) (arr :: FunArrow) = Fun k1 arr k2
listElim :: forall (a :: Type) (p :: [a] -> Type) (l :: [a]).
Sing l
-> p '[]
-> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> p xs -> p (x:xs))
-> p l
listElim = listElimPoly @(:->) @a @p @l
listElimTyFun :: forall (a :: Type) (p :: [a] ~> Type) (l :: [a]).
Sing l
-> p @@ '[]
-> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> p @@ xs -> p @@ (x:xs))
-> p @@ l
-- The line below causes a GHC panic. It should not typecheck;
-- uncomment the line below it for the correct version
listElimTyFun = listElimPoly @(:->) @a @p @l
-- listElimTyFun = listElimPoly @(:~>) @a @p @l
listElimPoly :: forall (arr :: FunArrow) (a :: Type) (p :: ([a] -?> Type) arr) (l :: [a]).
FunApp arr
=> Sing l
-> App [a] arr Type p '[]
-> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> App [a] arr Type p xs -> App [a] arr Type p (x:xs))
-> App [a] arr Type p l
listElimPoly SNil pNil _ = pNil
listElimPoly (SCons x (xs :: Sing xs)) pNil pCons = pCons x xs (listElimPoly @arr @a @p @xs xs pNil pCons)
```
```
$ /opt/ghc/8.2.1/bin/ghci Eliminator.hs
GHCi, version 8.2.0.20170623: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Eliminator ( Eliminator.hs, interpreted )
Eliminator.hs:72:17: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.2.0.20170623 for x86_64-unknown-linux):
No skolem info:
k2_a5cr
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1 |
| 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":"GHC panic: No skolem info: k2","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code causes a GHC panic on GHC 8.0.1, 8.0.2, 8.2.1, and HEAD:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE AllowAmbiguousTypes #-}\r\n{-# LANGUAGE ConstraintKinds #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE Trustworthy #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Eliminator where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing (a :: k)\r\ndata instance Sing (z :: [a]) where\r\n SNil :: Sing '[]\r\n SCons :: Sing x -> Sing xs -> Sing (x:xs)\r\n\r\ndata TyFun :: * -> * -> *\r\ntype a ~> b = TyFun a b -> *\r\ninfixr 0 ~>\r\n\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ntype a @@ b = Apply a b\r\ninfixl 9 @@\r\n\r\ndata FunArrow = (:->) | (:~>)\r\n\r\nclass FunType (arr :: FunArrow) where\r\n type Fun (k1 :: Type) arr (k2 :: Type) :: Type\r\n\r\nclass FunType arr => AppType (arr :: FunArrow) where\r\n type App k1 arr k2 (f :: Fun k1 arr k2) (x :: k1) :: k2\r\n\r\ntype FunApp arr = (FunType arr, AppType arr)\r\n\r\ninstance FunType (:->) where\r\n type Fun k1 (:->) k2 = k1 -> k2\r\n\r\n$(return []) -- This is only necessary for GHC 8.0 -- GHC 8.2 is smarter\r\n\r\ninstance AppType (:->) where\r\n type App k1 (:->) k2 (f :: k1 -> k2) x = f x\r\n\r\ninstance FunType (:~>) where\r\n type Fun k1 (:~>) k2 = k1 ~> k2\r\n\r\n$(return [])\r\n\r\ninstance AppType (:~>) where\r\n type App k1 (:~>) k2 (f :: k1 ~> k2) x = f @@ x\r\n\r\ninfixr 0 -?>\r\ntype (-?>) (k1 :: Type) (k2 :: Type) (arr :: FunArrow) = Fun k1 arr k2\r\n\r\nlistElim :: forall (a :: Type) (p :: [a] -> Type) (l :: [a]).\r\n Sing l\r\n -> p '[]\r\n -> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> p xs -> p (x:xs))\r\n -> p l\r\nlistElim = listElimPoly @(:->) @a @p @l\r\n\r\nlistElimTyFun :: forall (a :: Type) (p :: [a] ~> Type) (l :: [a]).\r\n Sing l\r\n -> p @@ '[]\r\n -> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> p @@ xs -> p @@ (x:xs))\r\n -> p @@ l\r\n-- The line below causes a GHC panic. It should not typecheck;\r\n-- uncomment the line below it for the correct version\r\nlistElimTyFun = listElimPoly @(:->) @a @p @l\r\n-- listElimTyFun = listElimPoly @(:~>) @a @p @l\r\n\r\nlistElimPoly :: forall (arr :: FunArrow) (a :: Type) (p :: ([a] -?> Type) arr) (l :: [a]).\r\n FunApp arr\r\n => Sing l\r\n -> App [a] arr Type p '[]\r\n -> (forall (x :: a) (xs :: [a]). Sing x -> Sing xs -> App [a] arr Type p xs -> App [a] arr Type p (x:xs))\r\n -> App [a] arr Type p l\r\nlistElimPoly SNil pNil _ = pNil\r\nlistElimPoly (SCons x (xs :: Sing xs)) pNil pCons = pCons x xs (listElimPoly @arr @a @p @xs xs pNil pCons)\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Eliminator.hs \r\nGHCi, version 8.2.0.20170623: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Eliminator ( Eliminator.hs, interpreted )\r\n\r\nEliminator.hs:72:17: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.2.0.20170623 for x86_64-unknown-linux):\r\n\tNo skolem info:\r\n k2_a5cr\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable\r\n callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13870Empty record construction for record-less constructor gives surprising runtim...2019-07-07T18:19:45ZRyan ScottEmpty record construction for record-less constructor gives surprising runtime error (and surprisingly few warnings)The crux of this ticket is this sort of code:
```hs
module Main where
f :: Maybe Int
f = Just{}
main :: IO ()
main = print f
```
```
$ runghc --ghc-arg=-Wall Bug.hs
Just Bug.hs: Bug.hs:4:5-10: Missing field in record construction
```...The crux of this ticket is this sort of code:
```hs
module Main where
f :: Maybe Int
f = Just{}
main :: IO ()
main = print f
```
```
$ runghc --ghc-arg=-Wall Bug.hs
Just Bug.hs: Bug.hs:4:5-10: Missing field in record construction
```
Yikes. There are a couple of very surprising things happening here.
First, the message `Missing field in record construction` is very misleading. After all, `Just` has no records! We really should give a more specific error which highlights this fact.
(The fact that you can even use record construction syntax with a record-less constructor in the first place is a bit baffling, but the [language standard does allow it](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-520003.15.2), so I suppose we have to live with this.)
The second surprising bit is the fact that is program compiled with no warnings whatsoever. This is in contrast to, say, the `Identity` datatype, which has a record (`runIdentity`):
```hs
module Main where
import Data.Functor.Identity
f :: Identity Int
f = Identity{}
main :: IO ()
main = print f
```
```
$ runghc --ghc-arg=-Wall Bug.hs
Bug.hs:6:5: warning: [-Wmissing-fields]
• Fields of ‘Identity’ not initialised: runIdentity
• In the expression: Identity {}
In an equation for ‘f’: f = Identity {}
Identity Bug.hs: Bug.hs:6:5-14: Missing field in record construction runIdentity
```
Here, GHC warned me that I was doing something stupid. GHC ought to be warning me with equivalent fervor when I use `Just{}`. The warning would obviously have to be tweaked a bit, since warning that `Fields of ‘Just’ not initialised` doesn't make any sense, but you get the idea.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.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":"Empty record construction for record-less constructor gives surprising runtime error (and surprisingly few warnings)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":["newcomer"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The crux of this ticket is this sort of code:\r\n\r\n{{{#!hs\r\nmodule Main where\r\n\r\nf :: Maybe Int\r\nf = Just{}\r\n\r\nmain :: IO ()\r\nmain = print f\r\n}}}\r\n{{{\r\n$ runghc --ghc-arg=-Wall Bug.hs\r\nJust Bug.hs: Bug.hs:4:5-10: Missing field in record construction\r\n}}}\r\n\r\nYikes. There are a couple of very surprising things happening here.\r\n\r\nFirst, the message `Missing field in record construction` is very misleading. After all, `Just` has no records! We really should give a more specific error which highlights this fact.\r\n\r\n(The fact that you can even use record construction syntax with a record-less constructor in the first place is a bit baffling, but the [https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-520003.15.2 language standard does allow it], so I suppose we have to live with this.)\r\n\r\nThe second surprising bit is the fact that is program compiled with no warnings whatsoever. This is in contrast to, say, the `Identity` datatype, which has a record (`runIdentity`):\r\n\r\n{{{#!hs\r\nmodule Main where\r\n\r\nimport Data.Functor.Identity\r\n\r\nf :: Identity Int\r\nf = Identity{}\r\n\r\nmain :: IO ()\r\nmain = print f\r\n}}}\r\n{{{\r\n$ runghc --ghc-arg=-Wall Bug.hs\r\n\r\nBug.hs:6:5: warning: [-Wmissing-fields]\r\n • Fields of ‘Identity’ not initialised: runIdentity\r\n • In the expression: Identity {}\r\n In an equation for ‘f’: f = Identity {}\r\nIdentity Bug.hs: Bug.hs:6:5-14: Missing field in record construction runIdentity\r\n}}}\r\n\r\nHere, GHC warned me that I was doing something stupid. GHC ought to be warning me with equivalent fervor when I use `Just{}`. The warning would obviously have to be tweaked a bit, since warning that `Fields of ‘Just’ not initialised` doesn't make any sense, but you get the idea.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1Tao Hesighingnow@gmail.comTao Hesighingnow@gmail.comhttps://gitlab.haskell.org/ghc/ghc/-/issues/13863-fno-code is broken on package:language-c-quote2019-07-07T18:19:47ZDouglas Wilsondouglas@well-typed.com-fno-code is broken on package:language-c-quotereported by awson here:
[https://github.com/haskell/haddock/issues/640](https://github.com/haskell/haddock/issues/640)
I think this is because QuasiQuotes should trigger object code generation.
I am also concerned how this interacts wi...reported by awson here:
[https://github.com/haskell/haddock/issues/640](https://github.com/haskell/haddock/issues/640)
I think this is because QuasiQuotes should trigger object code generation.
I am also concerned how this interacts with ANN pragmas.8.4.1Douglas Wilsondouglas@well-typed.comDouglas Wilsondouglas@well-typed.comhttps://gitlab.haskell.org/ghc/ghc/-/issues/13856"Zero-argument" lambda expressions from pretty-print strangely2019-07-07T18:19:49ZRyan Scott"Zero-argument" lambda expressions from pretty-print strangelyAn amusing corner case of the language is that you can constructor lambdas with zero arguments using Template Haskell:
```hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
f :: Int
f = $(lamE [] [| 42 |])
```
But if you ...An amusing corner case of the language is that you can constructor lambdas with zero arguments using Template Haskell:
```hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
f :: Int
f = $(lamE [] [| 42 |])
```
But if you try to compile that with `-ddump-splices` on, it'll look quite funny:
```
$ /opt/ghc/8.2.1/bin/ghci Bug.hs -ddump-splices
GHCi, version 8.2.0.20170616: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Main ( Bug.hs, interpreted )
Bug.hs:6:7-22: Splicing expression lamE [] [| 42 |] ======> \ -> 42
Ok, modules loaded: Main.
```
Oh dear, `\ -> 42` isn't a valid expression at all. The same thing happens with the Template Haskell pretty-printer:
```
λ> import Language.Haskell.TH
λ> :set -XTemplateHaskell
λ> putStrLn $(lamE [] [| 42 |] >>= stringE . pprint)
<interactive>:4:12-48: Splicing expression
lamE [] [| 42 |] >>= stringE . pprint ======> "\ -> 42"
\ -> 42
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"\"Zero-argument\" lambda expressions from pretty-print strangely","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"An amusing corner case of the language is that you can constructor lambdas with zero arguments using Template Haskell:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\n\r\nimport Language.Haskell.TH\r\n\r\nf :: Int\r\nf = $(lamE [] [| 42 |])\r\n}}}\r\n\r\nBut if you try to compile that with `-ddump-splices` on, it'll look quite funny:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Bug.hs -ddump-splices\r\nGHCi, version 8.2.0.20170616: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Main ( Bug.hs, interpreted )\r\nBug.hs:6:7-22: Splicing expression lamE [] [| 42 |] ======> \\ -> 42\r\nOk, modules loaded: Main.\r\n}}}\r\n\r\nOh dear, `\\ -> 42` isn't a valid expression at all. The same thing happens with the Template Haskell pretty-printer:\r\n\r\n{{{\r\nλ> import Language.Haskell.TH\r\nλ> :set -XTemplateHaskell\r\nλ> putStrLn $(lamE [] [| 42 |] >>= stringE . pprint)\r\n<interactive>:4:12-48: Splicing expression\r\n lamE [] [| 42 |] >>= stringE . pprint ======> \"\\ -> 42\"\r\n\\ -> 42\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/13847record construction accepts local unqualified name instead of qualified impor...2019-07-07T18:19:50Zwaldmann@imn.htwk-leipzig.derecord construction accepts local unqualified name instead of qualified imported nameGiven
```
module A where
data A = A { foo :: () } deriving Show
```
the following code is accepted
```
module Main where
import qualified A
foo = "foo"
main = print $ A.A { foo = () }
```
albeit with a warning
```
B.hs:4:16: warnin...Given
```
module A where
data A = A { foo :: () } deriving Show
```
the following code is accepted
```
module Main where
import qualified A
foo = "foo"
main = print $ A.A { foo = () }
```
albeit with a warning
```
B.hs:4:16: warning: [-Wmissing-fields]
• Fields of ‘A.A’ not initialised: foo
```
Indeed the `foo = ()` is type-checked as if it were `A.foo = ()`
but the `foo` field is actually not assigned. Evaluation gives
```
*Main> main
A {foo = *** Exception: B.hs:4:16-31: Missing field in record construction foo
```
The code should be rejected outright?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.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":"record construction accepts local unqualified name instead of qualified imported name","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Given\r\n{{{\r\nmodule A where\r\ndata A = A { foo :: () } deriving Show \r\n}}}\r\nthe following code is accepted \r\n{{{\r\nmodule Main where\r\nimport qualified A\r\nfoo = \"foo\"\r\nmain = print $ A.A { foo = () }\r\n}}}\r\nalbeit with a warning\r\n{{{\r\nB.hs:4:16: warning: [-Wmissing-fields]\r\n • Fields of ‘A.A’ not initialised: foo\r\n}}}\r\nIndeed the `foo = ()` is type-checked as if it were `A.foo = ()`\r\nbut the `foo` field is actually not assigned. Evaluation gives\r\n{{{\r\n*Main> main\r\nA {foo = *** Exception: B.hs:4:16-31: Missing field in record construction foo\r\n}}}\r\nThe code should be rejected outright?\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1