GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2020-02-24T21:36:31Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/15705Confusing parser error in 8.62020-02-24T21:36:31ZIavor S. DiatchkiConfusing parser error in 8.6Consider the following example:
```
f x =
case x of
A -> 'a'
B -> 'b'
```
The problem here is that `B` is misaligned, which is quite a common mistake, especially in a bigger case block.
GHC reports the following error:
```
...Consider the following example:
```
f x =
case x of
A -> 'a'
B -> 'b'
```
The problem here is that `B` is misaligned, which is quite a common mistake, especially in a bigger case block.
GHC reports the following error:
```
Unexpected case expression in function application:
case x of { A -> 'a' }
You could write it with parentheses
Or perhaps you meant to enable BlockArguments?
```
This is quite confusing, especially since the program won't parse, `BlockArguments` or not. My guess is that we are being a bit too eager with reporting the `BlockArguments` issue.
One way to work around this would be to just remember if we used `BlockArguments` while parsing, but only do the check that the extension is enabled after a successful parse.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 8.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Parser) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Confusing parser error in 8.6","status":"New","operating_system":"","component":"Compiler (Parser)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following example:\r\n{{{\r\nf x =\r\n case x of\r\n A -> 'a'\r\n B -> 'b'\r\n}}}\r\n\r\nThe problem here is that `B` is misaligned, which is quite a common mistake, especially in a bigger case block.\r\n\r\nGHC reports the following error:\r\n{{{\r\n Unexpected case expression in function application:\r\n case x of { A -> 'a' }\r\n You could write it with parentheses\r\n Or perhaps you meant to enable BlockArguments?\r\n}}}\r\nThis is quite confusing, especially since the program won't parse, `BlockArguments` or not. My guess is that we are being a bit too eager with reporting the `BlockArguments` issue.\r\n\r\nOne way to work around this would be to just remember if we used `BlockArguments` while parsing, but only do the check that the extension is enabled after a successful parse.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15674GADT's displayed type is misleading2019-07-07T18:03:29ZAntCGADT's displayed type is misleadingGHCi's `:t` alleges these three data constructors have the same type `:: Int -> T Int` (modulo name of the type constructor):
```hs
data DG a where MkDG :: Int -> DG Int
MkDG2 :: (a ~ Int) => a -> DG a
data...GHCi's `:t` alleges these three data constructors have the same type `:: Int -> T Int` (modulo name of the type constructor):
```hs
data DG a where MkDG :: Int -> DG Int
MkDG2 :: (a ~ Int) => a -> DG a
data family DF a
data instance DF Int where MkDF :: Int -> DF Int
```
I tried switching on verbosity flags, but to no avail: `-fprint-explicit-foralls, -fprint-equality-relations`, and a few others.
The `DG` constructors are GADTs, the `DF` constructor is not. So it's not hard to see different type-level behaviour:
```hs
f (MkDF x) = x -- accepted without a signature
-- f :: DF Int -> Int -- inferred signature, or you can spec it
-- f :: DF a -> a -- rejected: signature is too general/
-- a is a rigid type variable
g (MkDG x) = x -- } without a signature, rejected
g (MkDG2 x) = x -- } "untouchable" type (Note)
-- g :: DG Int -> Int -- } g accepted with either sig
-- g :: DG a -> a -- } ?but MkDG doesn't return DG a, allegedly
```
**Note:** at least the error message re `MkDG2` does show its type as `:: (forall a). (a ~ Int) => DG a -> a`. But doggedly `MkDG :: Int -> DG Int`.
"Untouchable" error messages are a fertile source of questions on StackOverflow. The message does say `Possible fix: add a type signature for 'g'`, but gives no clue what the signature might be.
If you've imported these data constructors from a library, such that you can't (easily) see they're GADTs, couldn't `:t` give you better help to show what's going on? Or should one of the verbosity flags already do this?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.6.1-beta1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Windows |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"GADT's displayed type is misleading","status":"New","operating_system":"Windows","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1-beta1","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"FeatureRequest","description":"GHCi's `:t` alleges these three data constructors have the same type `:: Int -> T Int` (modulo name of the type constructor):\r\n\r\n{{{#!hs\r\ndata DG a where MkDG :: Int -> DG Int \r\n MkDG2 :: (a ~ Int) => a -> DG a\r\n\r\ndata family DF a\r\ndata instance DF Int where MkDF :: Int -> DF Int\r\n}}}\r\n\r\nI tried switching on verbosity flags, but to no avail: `-fprint-explicit-foralls, -fprint-equality-relations`, and a few others.\r\n\r\nThe `DG` constructors are GADTs, the `DF` constructor is not. So it's not hard to see different type-level behaviour:\r\n\r\n{{{#!hs\r\nf (MkDF x) = x -- accepted without a signature\r\n-- f :: DF Int -> Int -- inferred signature, or you can spec it\r\n-- f :: DF a -> a -- rejected: signature is too general/\r\n -- a is a rigid type variable\r\n\r\ng (MkDG x) = x -- } without a signature, rejected\r\ng (MkDG2 x) = x -- } \"untouchable\" type (Note)\r\n\r\n-- g :: DG Int -> Int -- } g accepted with either sig \r\n-- g :: DG a -> a -- } ?but MkDG doesn't return DG a, allegedly\r\n}}}\r\n\r\n'''Note:''' at least the error message re `MkDG2` does show its type as `:: (forall a). (a ~ Int) => DG a -> a`. But doggedly `MkDG :: Int -> DG Int`.\r\n\r\n\"Untouchable\" error messages are a fertile source of questions on StackOverflow. The message does say `Possible fix: add a type signature for 'g'`, but gives no clue what the signature might be. \r\n\r\nIf you've imported these data constructors from a library, such that you can't (easily) see they're GADTs, couldn't `:t` give you better help to show what's going on? Or should one of the verbosity flags already do this?","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15618Unused binding warning should not apply to newtype constructors2019-07-07T18:03:43ZDavid FeuerUnused binding warning should not apply to newtype constructors```hs
module Foo (A, foo) where
import Data.Type.Coercion
newtype A = A Int
foo :: Coercion A Int
foo = Coercion
```
produces a warning:
```
NTCon.hs:4:13: warning: [-Wunused-top-binds]
Defined but not used: data constructor ‘A’
...```hs
module Foo (A, foo) where
import Data.Type.Coercion
newtype A = A Int
foo :: Coercion A Int
foo = Coercion
```
produces a warning:
```
NTCon.hs:4:13: warning: [-Wunused-top-binds]
Defined but not used: data constructor ‘A’
|
4 | newtype A = A Int
| ^^^^^
```
This is rather silly!
1. It's *impossible* to define a newtype without giving it a data constructor.
1. It's *possible* to use a newtype without using its data constructor.
Therefore, I believe the only reasonable thing to do is suppress the unused binding warning for newtype data constructors. If the newtype itself isn't used, that will be caught anyway.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.1-beta1 |
| 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":"Unused binding warning should not apply to newtype constructors","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1-beta1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\nmodule Foo (A, foo) where\r\nimport Data.Type.Coercion\r\n\r\nnewtype A = A Int\r\n\r\nfoo :: Coercion A Int\r\nfoo = Coercion\r\n}}}\r\n\r\nproduces a warning:\r\n\r\n{{{\r\nNTCon.hs:4:13: warning: [-Wunused-top-binds]\r\n Defined but not used: data constructor ‘A’\r\n |\r\n4 | newtype A = A Int\r\n | ^^^^^\r\n}}}\r\n\r\nThis is rather silly!\r\n\r\n1. It's ''impossible'' to define a newtype without giving it a data constructor.\r\n\r\n2. It's ''possible'' to use a newtype without using its data constructor.\r\n\r\nTherefore, I believe the only reasonable thing to do is suppress the unused binding warning for newtype data constructors. If the newtype itself isn't used, that will be caught anyway.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15617Unboxed tuples/sum error message on `a = show 5` in expression evaluation and...2020-09-01T07:48:09ZChaiTRexUnboxed tuples/sum error message on `a = show 5` in expression evaluation and interactive modesWith GHC 8.4.3 (on both Ubuntu 16.04.5 and Ubuntu 18.04.1) and recent GHC (not `HEAD` but close at `ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183` on Ubuntu 16.04.5), I get errors for `a = show 5`.
I run the following commands, showing that ...With GHC 8.4.3 (on both Ubuntu 16.04.5 and Ubuntu 18.04.1) and recent GHC (not `HEAD` but close at `ff29fc84c03c800cfa04c2a00eb8edf6fa5f4183` on Ubuntu 16.04.5), I get errors for `a = show 5`.
I run the following commands, showing that `show 5` is usually fine:
```
$ ghc -fobject-code -O2 -e 'show 5'
"5"
$ ghc -fobject-code -O2 -e 'let a = show 5 in a'
"5"
```
But not with `a = show 5`:
```
$ ghc -fobject-code -O2 -e 'a = show 5'
<interactive>: Error: bytecode compiler can't handle unboxed tuples and sums.
Possibly due to foreign import/export decls in source.
Workaround: use -fobject-code, or compile this module to .o separately.
```
Running with `ghci` gives the same error:
```
$ ghci -fobject-code -O2
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Prelude> a = show 5
Error: bytecode compiler can't handle unboxed tuples and sums.
Possibly due to foreign import/export decls in source.
Workaround: use -fobject-code, or compile this module to .o separately.
Prelude>
Leaving GHCi.
```
Both errors stop when optimization is turned off:
```
$ ghc -fobject-code -O0 -e 'a = show 5'
$ ghci -fobject-code -O0
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Prelude> a = show 5
Prelude>
Leaving GHCi.
```8.6.1Roland SennRoland Sennhttps://gitlab.haskell.org/ghc/ghc/-/issues/15601Unexpected compile error on type level lists with a single element2019-07-07T18:03:47ZerikdUnexpected compile error on type level lists with a single elementTried this with ghc 8.0.2, 8.2.2 and 8.4.3 and all give an almost identical error on the following piece of code:
```hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOpe...Tried this with ghc 8.0.2, 8.2.2 and 8.4.3 and all give an almost identical error on the following piece of code:
```hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wall #-}
import Data.Singletons.Prelude.List
#if MIN_VERSION_singletons(2,4,0)
type (a :++ b) = a ++ b
#endif
data MyType = A | B | C | D | E | F
type TypeList1 = ['A, 'B]
type TypeList2 = TypeList1 :++ ['C, 'D]
-- Everything above is fine, but this line:
type TypeList3 = TypeList2 :++ ['F]
-- Gives the error:
--
-- type-level-list.hs:21:32: error:
-- • Expected kind ‘[MyType]’, but ‘[ 'F]’ has kind ‘*’
-- • In the second argument of ‘(:++)’, namely ‘[ 'F]’
-- In the type ‘TypeList2 :++ [ 'F]’
-- In the type declaration for ‘TypeList3’
-- |
-- 22 | type TypeList3 = TypeList2 :++ ['F]
-- If instead I write it like:
type TypeList4 = TypeList2 :++ '[F]
-- I get the warning:
--
-- type-level-list.hs:33:34: warning: [-Wunticked-promoted-constructors]
-- Unticked promoted constructor: ‘F’.
-- Use ‘'F’ instead of ‘F’.
-- The following actually seems to work, but I don't understand why type level
-- lists containing only one element are different.
type TypeList5 = TypeList2 :++ '[ 'F]
```
<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":"Unexpected compile error on type level lists with a single element","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":"Tried this with ghc 8.0.2, 8.2.2 and 8.4.3 and all give an almost identical error on the following piece of code:\r\n{{{#!hs\r\n\r\n{-# LANGUAGE FlexibleContexts #-}\r\n{-# LANGUAGE FlexibleInstances #-}\r\n{-# LANGUAGE DataKinds #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE CPP #-}\r\n\r\n{-# OPTIONS_GHC -Wall #-}\r\n\r\nimport Data.Singletons.Prelude.List\r\n\r\n#if MIN_VERSION_singletons(2,4,0)\r\ntype (a :++ b) = a ++ b\r\n#endif\r\n\r\ndata MyType = A | B | C | D | E | F\r\n\r\ntype TypeList1 = ['A, 'B]\r\n\r\ntype TypeList2 = TypeList1 :++ ['C, 'D]\r\n\r\n-- Everything above is fine, but this line:\r\ntype TypeList3 = TypeList2 :++ ['F]\r\n-- Gives the error:\r\n--\r\n-- type-level-list.hs:21:32: error:\r\n-- • Expected kind ‘[MyType]’, but ‘[ 'F]’ has kind ‘*’\r\n-- • In the second argument of ‘(:++)’, namely ‘[ 'F]’\r\n-- In the type ‘TypeList2 :++ [ 'F]’\r\n-- In the type declaration for ‘TypeList3’\r\n-- |\r\n-- 22 | type TypeList3 = TypeList2 :++ ['F]\r\n\r\n-- If instead I write it like:\r\ntype TypeList4 = TypeList2 :++ '[F]\r\n-- I get the warning:\r\n--\r\n-- type-level-list.hs:33:34: warning: [-Wunticked-promoted-constructors]\r\n-- Unticked promoted constructor: ‘F’.\r\n-- Use ‘'F’ instead of ‘F’.\r\n\r\n-- The following actually seems to work, but I don't understand why type level \r\n-- lists containing only one element are different.\r\ntype TypeList5 = TypeList2 :++ '[ 'F]\r\n\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15527TypeApplications error message doesn't parenthesize infix name2019-07-07T18:04:18ZRyan ScottTypeApplications error message doesn't parenthesize infix nameIf you compile the following program:
```hs
module Bug where
f :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)
f = (.) @Int
```
You'll get this error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs,...If you compile the following program:
```hs
module Bug where
f :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)
f = (.) @Int
```
You'll get this error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:4:6: error:
Pattern syntax in expression context: .@Int
Did you mean to enable TypeApplications?
|
4 | f = (.) @Int
| ^^^^^^^^
```
I was taken aback by this strange `.@` thing before I realized what was actually going on: the error message simply forgot to parenthesize `.`. This is `ppr_expr`'s fault, since it calls `ppr` on an `RdrName` instead of `pprPrefixOcc`. Patch incoming.
<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":"TypeApplications error message doesn't parenthesize infix name","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeApplications"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If you compile the following program:\r\n\r\n{{{#!hs\r\nmodule Bug where\r\n\r\nf :: (Int -> Int) -> (Int -> Int) -> (Int -> Int)\r\nf = (.) @Int\r\n}}}\r\n\r\nYou'll get this error:\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:4:6: error:\r\n Pattern syntax in expression context: .@Int\r\n Did you mean to enable TypeApplications?\r\n |\r\n4 | f = (.) @Int\r\n | ^^^^^^^^\r\n}}}\r\n\r\nI was taken aback by this strange `.@` thing before I realized what was actually going on: the error message simply forgot to parenthesize `.`. This is `ppr_expr`'s fault, since it calls `ppr` on an `RdrName` instead of `pprPrefixOcc`. Patch incoming.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15498HPC: do notation marks () as non-covered2019-07-07T18:04:29Ztom-bopHPC: do notation marks () as non-coveredWith this Main.hs, the "()" in "pure ()" is marked by HPC as a non-covered expression:
```hs
foo :: IO ()
foo = do
_ <- putStrLn "Unimportant string"
pure ()
main :: IO ()
main = do
foo
putStrLn "Unimportant #2"
```
Repro:...With this Main.hs, the "()" in "pure ()" is marked by HPC as a non-covered expression:
```hs
foo :: IO ()
foo = do
_ <- putStrLn "Unimportant string"
pure ()
main :: IO ()
main = do
foo
putStrLn "Unimportant #2"
```
Repro:
> - `ghc -fhpc Main.hs`
> - `./Main`
> - `hpc markup Main.tix`
This is an admittedly small issue, but it can be valuable for a project to aspire to 100% code coverage and false negatives prevent us from getting there.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------- |
| Version | 8.2.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Code Coverage |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"HPC: do notation marks () as non-covered","status":"New","operating_system":"","component":"Code Coverage","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"With this Main.hs, the \"()\" in \"pure ()\" is marked by HPC as a non-covered expression:\r\n\r\n{{{#!hs\r\nfoo :: IO ()\r\nfoo = do\r\n _ <- putStrLn \"Unimportant string\"\r\n pure ()\r\n\r\nmain :: IO ()\r\nmain = do\r\n foo\r\n putStrLn \"Unimportant #2\"\r\n}}}\r\n\r\nRepro:\r\n - `ghc -fhpc Main.hs`\r\n - `./Main`\r\n - `hpc markup Main.tix`\r\n\r\nThis is an admittedly small issue, but it can be valuable for a project to aspire to 100% code coverage and false negatives prevent us from getting there.\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15458Misleading error message on mising BangPatterns extension2019-07-07T18:04:46ZSergey VinokurovMisleading error message on mising BangPatterns extensionFor following program I'm getting an unexpected error message.
```hs
foo :: Int -> Int
foo = bar
where
bar :: Int -> Int
bar !i = i
```
```
$ ghc -o Test Test.hs
[1 of 1] Compiling Main ( Test.hs, Test.o )
Test.h...For following program I'm getting an unexpected error message.
```hs
foo :: Int -> Int
foo = bar
where
bar :: Int -> Int
bar !i = i
```
```
$ ghc -o Test Test.hs
[1 of 1] Compiling Main ( Test.hs, Test.o )
Test.hs:4:5: error:
The type signature for ‘bar’ lacks an accompanying binding
|
4 | bar :: Int -> Int
| ^^^
```
Enabling `-XBangPatterns` fixes the issue but I wanted the compiler to suggest me to enable it:
```
$ ghc -XBangPatterns -o Test Test.hs
[1 of 1] Compiling Main ( Test.hs, Test.o )
Test.hs:1:1: error:
The IO action ‘main’ is not defined in module ‘Main’
|
1 | foo :: Int -> Int
| ^
```
<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":"Misleading error message on mising BangPatterns extension","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":"For following program I'm getting an unexpected error message.\r\n\r\n{{{#!hs\r\nfoo :: Int -> Int\r\nfoo = bar\r\n where\r\n bar :: Int -> Int\r\n bar !i = i\r\n}}}\r\n\r\n{{{\r\n$ ghc -o Test Test.hs\r\n[1 of 1] Compiling Main ( Test.hs, Test.o )\r\n\r\nTest.hs:4:5: error:\r\n The type signature for ‘bar’ lacks an accompanying binding\r\n |\r\n4 | bar :: Int -> Int\r\n | ^^^\r\n}}}\r\n\r\nEnabling `-XBangPatterns` fixes the issue but I wanted the compiler to suggest me to enable it:\r\n{{{\r\n$ ghc -XBangPatterns -o Test Test.hs\r\n[1 of 1] Compiling Main ( Test.hs, Test.o )\r\n\r\nTest.hs:1:1: error:\r\n The IO action ‘main’ is not defined in module ‘Main’\r\n |\r\n1 | foo :: Int -> Int\r\n | ^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15450Inconsistency w.r.t. coverage checking warnings for EmptyCase under unsatisfi...2020-09-30T15:54:07ZRyan ScottInconsistency w.r.t. coverage checking warnings for EmptyCase under unsatisfiable constraintsConsider the following code:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Bug where
f :: (Int ~ Bool) => Bool -> a
f x = case x of {}
g :: (Int ~ Bool) => Bool -> a
g x = cas...Consider the following code:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Bug where
f :: (Int ~ Bool) => Bool -> a
f x = case x of {}
g :: (Int ~ Bool) => Bool -> a
g x = case x of True -> undefined
```
```
$ /opt/ghc/8.4.3/bin/ghci Bug.hs
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:10:7: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: False
|
10 | g x = case x of True -> undefined
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Observe that we get a non-exhaustivity warning for the `case` expression in `g` (thanks to commit adb565aa74582969bbcc3b411d6d518b1c76c3cf), but not for the one in `f`. The difference is that `f` uses `EmptyCase`, whereas `g` does not, and the codepath for `EmptyCase` is unfortunately incongruous with the codepath for other coverage checking.
I know how to fix this. Patch incoming.
<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":"Inconsistency w.r.t. coverage checking warnings for EmptyCase under unsatisfiable constraints","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["PatternMatchWarnings"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following code:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE EmptyCase #-}\r\n{-# LANGUAGE GADTs #-}\r\n{-# OPTIONS_GHC -Wincomplete-patterns #-}\r\nmodule Bug where\r\n\r\nf :: (Int ~ Bool) => Bool -> a\r\nf x = case x of {}\r\n\r\ng :: (Int ~ Bool) => Bool -> a\r\ng x = case x of True -> undefined\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghci Bug.hs\r\nGHCi, version 8.4.3: 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:10:7: warning: [-Wincomplete-patterns]\r\n Pattern match(es) are non-exhaustive\r\n In a case alternative: Patterns not matched: False\r\n |\r\n10 | g x = case x of True -> undefined\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nObserve that we get a non-exhaustivity warning for the `case` expression in `g` (thanks to commit adb565aa74582969bbcc3b411d6d518b1c76c3cf), but not for the one in `f`. The difference is that `f` uses `EmptyCase`, whereas `g` does not, and the codepath for `EmptyCase` is unfortunately incongruous with the codepath for other coverage checking.\r\n\r\nI know how to fix this. Patch incoming.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15393Regression: Detection of unused imports is imprecise (since GHC 8.0.1)2019-07-07T18:12:50ZSimon Hengelsol@typeful.netRegression: Detection of unused imports is imprecise (since GHC 8.0.1)GHCs detection of unused imports used to be very precise. But apparently this changed with GHC 8.0.1. I already noticed for a while that there is something fishy going on and finally came up with a minimal example.
## Steps to reproduce...GHCs detection of unused imports used to be very precise. But apparently this changed with GHC 8.0.1. I already noticed for a while that there is something fishy going on and finally came up with a minimal example.
## Steps to reproduce:
```hs
-- Bar.hs
module Bar (bar, module Control.Monad) where
import Control.Monad
bar :: Integer
bar = 23
```
```hs
-- Foo.hs
module Foo where
import Bar
import Control.Monad (forM_)
foo :: Monad m => [a] -> (a -> m ()) -> m ()
foo = forM_
baz :: Integer
baz = bar
```
```
$ ghci -Wall -Werror Foo.hs
```
- \*Expected result:\*\* The program is reject.
- \*Actual result:\*\* The program was reject by GHC \< 8.0.1, however later versions of GHC accept the program.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"Regression: Detection of unused imports is imprecise (since GHC 8.0.1)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHCs detection of unused imports used to be very precise. But apparently this changed with GHC 8.0.1. I already noticed for a while that there is something fishy going on and finally came up with a minimal example.\r\n\r\n== Steps to reproduce:\r\n\r\n{{{#!hs\r\n-- Bar.hs\r\nmodule Bar (bar, module Control.Monad) where\r\n\r\nimport Control.Monad\r\n\r\nbar :: Integer\r\nbar = 23\r\n}}}\r\n\r\n{{{#!hs\r\n-- Foo.hs\r\nmodule Foo where\r\n\r\nimport Bar\r\nimport Control.Monad (forM_)\r\n\r\nfoo :: Monad m => [a] -> (a -> m ()) -> m ()\r\nfoo = forM_\r\n\r\nbaz :: Integer\r\nbaz = bar\r\n}}}\r\n\r\n{{{\r\n$ ghci -Wall -Werror Foo.hs\r\n}}}\r\n\r\n**Expected result:** The program is reject.\r\n\r\n**Actual result:** The program was reject by GHC < 8.0.1, however later versions of GHC accept the program.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15361Error message displays redundant equality constraint2019-07-07T18:13:00ZRyan ScottError message displays redundant equality constraintWhen compiling this program:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind
import Data.Type.Equality
foo :: forall (a :: Type)...When compiling this program:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind
import Data.Type.Equality
foo :: forall (a :: Type) (b :: Type) (c :: Type).
a :~~: b -> a :~~: c
foo HRefl = HRefl
```
GHC complains thus:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:13: error:
• Could not deduce: a ~ c
from the context: (* ~ *, b ~ a)
bound by a pattern with constructor:
HRefl :: forall k1 (a :: k1). a :~~: a,
in an equation for ‘foo’
at Bug.hs:12:5-9
‘a’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) -> a :~~: c
at Bug.hs:(10,1)-(11,27)
‘c’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) -> a :~~: c
at Bug.hs:(10,1)-(11,27)
Expected type: a :~~: c
Actual type: a :~~: a
• In the expression: HRefl
In an equation for ‘foo’: foo HRefl = HRefl
• Relevant bindings include
foo :: (a :~~: b) -> a :~~: c (bound at Bug.hs:12:1)
|
12 | foo HRefl = HRefl
| ^^^^^
```
That `* ~ *` constraint is entirely redundant.
<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":"Error message displays redundant equality constraint","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiling this program:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE KindSignatures #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\nfoo :: forall (a :: Type) (b :: Type) (c :: Type).\r\n a :~~: b -> a :~~: c\r\nfoo HRefl = HRefl\r\n}}}\r\n\r\nGHC complains thus:\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:12:13: error:\r\n • Could not deduce: a ~ c\r\n from the context: (* ~ *, b ~ a)\r\n bound by a pattern with constructor:\r\n HRefl :: forall k1 (a :: k1). a :~~: a,\r\n in an equation for ‘foo’\r\n at Bug.hs:12:5-9\r\n ‘a’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) -> a :~~: c\r\n at Bug.hs:(10,1)-(11,27)\r\n ‘c’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) -> a :~~: c\r\n at Bug.hs:(10,1)-(11,27)\r\n Expected type: a :~~: c\r\n Actual type: a :~~: a\r\n • In the expression: HRefl\r\n In an equation for ‘foo’: foo HRefl = HRefl\r\n • Relevant bindings include\r\n foo :: (a :~~: b) -> a :~~: c (bound at Bug.hs:12:1)\r\n |\r\n12 | foo HRefl = HRefl\r\n | ^^^^^\r\n}}}\r\n\r\nThat `* ~ *` constraint is entirely redundant.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15321Typed holes in Template Haskell splices produce bewildering error messages2019-07-07T18:13:14ZRyan ScottTyped holes in Template Haskell splices produce bewildering error messagesIf you compile this program with GHC 8.4 or later:
```hs
{-# LANGUAGE TemplateHaskell #-}
module Bug where
foo :: String
foo = test
bar :: String
bar = $(_ "baz")
```
You'll be greeted with a rather strange error message:
```
$ /opt...If you compile this program with GHC 8.4 or later:
```hs
{-# LANGUAGE TemplateHaskell #-}
module Bug where
foo :: String
foo = test
bar :: String
bar = $(_ "baz")
```
You'll be greeted with a rather strange error message:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:8:7: error:
• GHC stage restriction:
‘foo’ is used in a top-level splice, quasi-quote, or annotation,
and must be imported, not defined locally
• In the untyped splice: $(_ "baz")
|
8 | bar = $(_ "baz")
| ^^^^^^^^^^
```
`foo` has nothing do with how `bar`'s RHS should be typechecked, so why is it being mentioned in the error message?
In contrast, GHC 8.2 and earlier gives you quite a nice error message:
```
$ /opt/ghc/8.2.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:8:9: error:
• Found hole: _ :: [Char] -> Language.Haskell.TH.Lib.ExpQ
• In the expression: _
In the expression: _ "baz"
In the untyped splice: $(_ "baz")
|
8 | bar = $(_ "baz")
| ^
```
Tritlo, my hunch is that the valid hole fits stuff is the culprit here. Do you think that perhaps when building the subsumption graph, we are trying to check the hole's type against that of `foo`, which causes the stage restriction error? If so, do you think it is possible to work around this?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | Tritlo |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Typed holes in Template Haskell splices produce bewildering error messages","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypedHoles"],"differentials":[],"test_case":"","architecture":"","cc":["Tritlo"],"type":"Bug","description":"If you compile this program with GHC 8.4 or later:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\nmodule Bug where\r\n\r\nfoo :: String\r\nfoo = test\r\n\r\nbar :: String\r\nbar = $(_ \"baz\")\r\n}}}\r\n\r\nYou'll be greeted with a rather strange error message:\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:8:7: error:\r\n • GHC stage restriction:\r\n ‘foo’ is used in a top-level splice, quasi-quote, or annotation,\r\n and must be imported, not defined locally\r\n • In the untyped splice: $(_ \"baz\")\r\n |\r\n8 | bar = $(_ \"baz\")\r\n | ^^^^^^^^^^\r\n}}}\r\n\r\n`foo` has nothing do with how `bar`'s RHS should be typechecked, so why is it being mentioned in the error message?\r\n\r\nIn contrast, GHC 8.2 and earlier gives you quite a nice error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:8:9: error:\r\n • Found hole: _ :: [Char] -> Language.Haskell.TH.Lib.ExpQ\r\n • In the expression: _\r\n In the expression: _ \"baz\"\r\n In the untyped splice: $(_ \"baz\")\r\n |\r\n8 | bar = $(_ \"baz\")\r\n | ^\r\n}}}\r\n\r\nTritlo, my hunch is that the valid hole fits stuff is the culprit here. Do you think that perhaps when building the subsumption graph, we are trying to check the hole's type against that of `foo`, which causes the stage restriction error? If so, do you think it is possible to work around this?","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15308Error message prints explicit kinds when it shouldn't2019-07-07T18:13:20ZRyan ScottError message prints explicit kinds when it shouldn'tWhen compiled, this program:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
{-# OPTIONS_GHC -fno-print-explicit-kinds #-}
module Bug where
import Data.Kind
data Foo (a :: Type) :: forall ...When compiled, this program:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
{-# OPTIONS_GHC -fno-print-explicit-kinds #-}
module Bug where
import Data.Kind
data Foo (a :: Type) :: forall b. (a -> b -> Type) -> Type where
MkFoo :: Foo a f
f :: Foo a f -> String
f = show
```
Gives the following error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
|
13 | f = show
| ^^^^
```
This error message is slightly incorrect, however. In "`No instance for (Show (Foo a b f))`", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `-fno-print-explicit-kinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)
This is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:
```
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
```
But it does not in GHC 8.2.1:
```
$ /opt/ghc/8.2.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
|
13 | f = show
| ^^^^
```
<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":"Error message prints explicit kinds when it shouldn't","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiled, this program:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# OPTIONS_GHC -fno-print-explicit-kinds #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata Foo (a :: Type) :: forall b. (a -> b -> Type) -> Type where\r\n MkFoo :: Foo a f\r\n\r\nf :: Foo a f -> String\r\nf = show\r\n}}}\r\n\r\nGives the following error:\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:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n |\r\n13 | f = show\r\n | ^^^^\r\n}}}\r\n\r\nThis error message is slightly incorrect, however. In \"`No instance for (Show (Foo a b f))`\", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `-fno-print-explicit-kinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)\r\n\r\nThis is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n}}}\r\n\r\nBut it does not in GHC 8.2.1:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n |\r\n13 | f = show\r\n | ^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15264Warn about implicit kind variables with -Wcompat2019-07-07T18:13:34ZVladislav ZavialovWarn about implicit kind variables with -WcompatAccording to an accepted proposal https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst:
> With `-Wcompat`, warn if a kind variable is brought into scope implicitly in a type with an explicit `forall...According to an accepted proposal https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst:
> With `-Wcompat`, warn if a kind variable is brought into scope implicitly in a type with an explicit `forall`. This applies to type signatures and to other contexts that allow a `forall` with the forall-or-nothing rule in effect (for example, class instances).
Creating ticket just for the record. Implementation coming soon.8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15232TypeError is reported as "redundant constraint" starting with GHC 8.22019-07-07T18:13:41ZfsoikinTypeError is reported as "redundant constraint" starting with GHC 8.2The following program compiles fine on GHC 8.0.2, but GHC 8.2.2 issues a warning, complaining that `TypeError` is a redundant constraint. This makes it very inconvenient to use `TypeError` with type classes.
```hs
{-# OPTIONS_GHC -Wredu...The following program compiles fine on GHC 8.0.2, but GHC 8.2.2 issues a warning, complaining that `TypeError` is a redundant constraint. This makes it very inconvenient to use `TypeError` with type classes.
```hs
{-# OPTIONS_GHC -Wredundant-constraints -Wall -Werror #-}
import GHC.TypeLits (TypeError, ErrorMessage(..))
class C a where f :: a -> a
instance {-# OVERLAPPING #-} C Int where f _ = 42
instance {-# OVERLAPPABLE #-} TypeError ( 'Text "Only Int is supported" ) => C a where f = undefined
main :: IO ()
main = print $ f (42::Int)
```
<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 | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"TypeError is reported as \"redundant constraint\" starting with GHC 8.2","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.2.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["CustomTypeErrors"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program compiles fine on GHC 8.0.2, but GHC 8.2.2 issues a warning, complaining that `TypeError` is a redundant constraint. This makes it very inconvenient to use `TypeError` with type classes.\r\n\r\n{{{#!hs\r\n{-# OPTIONS_GHC -Wredundant-constraints -Wall -Werror #-}\r\nimport GHC.TypeLits (TypeError, ErrorMessage(..))\r\n\r\nclass C a where f :: a -> a\r\ninstance {-# OVERLAPPING #-} C Int where f _ = 42\r\ninstance {-# OVERLAPPABLE #-} TypeError ( 'Text \"Only Int is supported\" ) => C a where f = undefined\r\n\r\nmain :: IO ()\r\nmain = print $ f (42::Int)\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15166Bad error message when `!` is used without BangPatterns extension2019-07-07T18:13:57ZTao Hesighingnow@gmail.comBad error message when `!` is used without BangPatterns extensionFor
```hs
f :: a -> a
f !x = x
```
ghc-HEAD gives
```
P.hs:22:1: error:
The type signature for ‘f’ lacks an accompanying binding
|
22 | f :: a -> a
| ^
```
Here ghc should suggest `BangPatterns` extension.
<details><summar...For
```hs
f :: a -> a
f !x = x
```
ghc-HEAD gives
```
P.hs:22:1: error:
The type signature for ‘f’ lacks an accompanying binding
|
22 | f :: a -> a
| ^
```
Here ghc should suggest `BangPatterns` extension.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.5 |
| 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":"Bad error message when `!` is used without BangPatterns extension","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"For\r\n\r\n{{{#!hs\r\nf :: a -> a\r\nf !x = x\r\n}}}\r\n\r\nghc-HEAD gives\r\n\r\n{{{\r\nP.hs:22:1: error:\r\n The type signature for ‘f’ lacks an accompanying binding\r\n |\r\n22 | f :: a -> a\r\n | ^\r\n}}}\r\n\r\nHere ghc should suggest `BangPatterns` extension.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15139EmptyCase produces incorrect SrcSpans2019-07-07T18:14:06ZRyan ScottEmptyCase produces incorrect SrcSpansIf you compile the following program, you'll get a warning for `f` with an improperly placed `SrcSpan`:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Bug where
import D...If you compile the following program, you'll get a warning for `f` with an improperly placed `SrcSpan`:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Bug where
import Data.Type.Equality
can'tHappen :: Int :~: Bool
can'tHappen = undefined
f, g :: Bool -> Bool
f True = case can'tHappen of {}
g True = case () of () -> True
```
```
$ /opt/ghc/8.4.2/bin/ghci Bug.hs
GHCi, version 8.4.2: 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:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘f’: Patterns not matched: False
|
12 | f True = case can'tHappen of {}
| ^^^^^^^^^^^^^
Bug.hs:13:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘g’: Patterns not matched: False
|
13 | g True = case () of () -> True
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Ok, one module loaded.
```
Compare that to the warning for `g`, whose `SrcSpan` spans the entire clause, as expected.
The bug lies in the parser—patch incoming.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 8.4.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Parser) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"EmptyCase produces incorrect SrcSpans","status":"New","operating_system":"","component":"Compiler (Parser)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If you compile the following program, you'll get a warning for `f` with an improperly placed `SrcSpan`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE EmptyCase #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# OPTIONS_GHC -Wincomplete-patterns #-}\r\nmodule Bug where\r\n\r\nimport Data.Type.Equality\r\n\r\ncan'tHappen :: Int :~: Bool\r\ncan'tHappen = undefined\r\n\r\nf, g :: Bool -> Bool\r\nf True = case can'tHappen of {}\r\ng True = case () of () -> True\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghci Bug.hs\r\nGHCi, version 8.4.2: 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:1: warning: [-Wincomplete-patterns]\r\n Pattern match(es) are non-exhaustive\r\n In an equation for ‘f’: Patterns not matched: False\r\n |\r\n12 | f True = case can'tHappen of {}\r\n | ^^^^^^^^^^^^^\r\n\r\nBug.hs:13:1: warning: [-Wincomplete-patterns]\r\n Pattern match(es) are non-exhaustive\r\n In an equation for ‘g’: Patterns not matched: False\r\n |\r\n13 | g True = case () of () -> True\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nOk, one module loaded.\r\n}}}\r\n\r\nCompare that to the warning for `g`, whose `SrcSpan` spans the entire clause, as expected.\r\n\r\nThe bug lies in the parser—patch incoming.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15039Bizarre pretty-printing of inferred Coercible constraint in partial type sign...2019-07-07T18:14:36ZRyan ScottBizarre pretty-printing of inferred Coercible constraint in partial type signatureConsider the following GHCi session:
```
$ ghci
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> import Data.Type.Coercion
λ> foo :: _ => Coercion a b; foo = Coercion
<...Consider the following GHCi session:
```
$ ghci
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> import Data.Type.Coercion
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:2:8: error:
• Found type wildcard ‘_’
standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of foo :: Coercible a b => Coercion a b
at <interactive>:2:27-40
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
λ> :set -fprint-explicit-kinds
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:4:8: error:
• Found type wildcard ‘_’
standing for ‘(a :: *) ~~ (b :: *) :: TYPE
('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of
foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b
at <interactive>:4:27-40
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
```
There are two things quite strange about this:
1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.
1. For some reason, enabling `-fprint-explicit-kinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.4.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":"Bizarre pretty-printing of inferred Coercible constraint in partial type signature","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["PartialTypeSignatures"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following GHCi session:\r\n\r\n{{{\r\n$ ghci\r\nGHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\nλ> import Data.Type.Coercion\r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:2:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of foo :: Coercible a b => Coercion a b\r\n at <interactive>:2:27-40\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\nλ> :set -fprint-explicit-kinds \r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:4:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘(a :: *) ~~ (b :: *) :: TYPE\r\n ('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of\r\n foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b\r\n at <interactive>:4:27-40\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\n}}}\r\n\r\nThere are two things quite strange about this:\r\n\r\n1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.\r\n2. For some reason, enabling `-fprint-explicit-kinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15026Type deduction panic2019-07-07T18:14:38ZmoominType deduction panic```lhs
> {-# LANGUAGE DeriveFunctor #-}
> module Bug where
> import qualified Data.Set as S
> import Data.Foldable (fold, foldMap, toList)
> import Data.List.Split (splitOn)
> import Data.Monoid -- ((<>), Sum, mempty, mappend)
> imp...```lhs
> {-# LANGUAGE DeriveFunctor #-}
> module Bug where
> import qualified Data.Set as S
> import Data.Foldable (fold, foldMap, toList)
> import Data.List.Split (splitOn)
> import Data.Monoid -- ((<>), Sum, mempty, mappend)
> import Data.Functor.Foldable
> newtype Component = Component (Int,Int) deriving (Eq, Ord, Show)
> data Day24State v a = Day24State {
> valueToMatch :: Int,
> componentsToUse :: S.Set Component,
> componentMetric :: v,
> nextStates :: [a]
> } deriving (Functor, Show)
> type Day24StateFix v a = Fix (Day24State v)
```
Now in GHCI type
> :t Data.Functor.Foldable.ana f (undefined :: Day24StateFix Component)
Produces
ghc.EXE: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-mingw32):
> initTc: unsolved constraints
> WC {wc_insol = \[W\] f_akbJ :: t_akbI\[tau:3\] (CHoleCan: f)}
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 | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type deduction panic","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!lhs\r\n> {-# LANGUAGE DeriveFunctor #-}\r\n\r\n> module Bug where \r\n\r\n> import qualified Data.Set as S \r\n\r\n> import Data.Foldable (fold, foldMap, toList)\r\n> import Data.List.Split (splitOn)\r\n> import Data.Monoid -- ((<>), Sum, mempty, mappend)\r\n> import Data.Functor.Foldable\r\n\r\n> newtype Component = Component (Int,Int) deriving (Eq, Ord, Show)\r\n\r\n> data Day24State v a = Day24State {\r\n> valueToMatch :: Int,\r\n> componentsToUse :: S.Set Component,\r\n> componentMetric :: v,\r\n> nextStates :: [a] \r\n> } deriving (Functor, Show)\r\n\r\n> type Day24StateFix v a = Fix (Day24State v) \r\n}}}\r\n\r\nNow in GHCI type\r\n\r\n> :t Data.Functor.Foldable.ana f (undefined :: Day24StateFix Component)\r\n\r\nProduces\r\n\r\nghc.EXE: panic! (the 'impossible' happened)\r\n (GHC version 8.0.2 for x86_64-unknown-mingw32):\r\n initTc: unsolved constraints\r\n WC {wc_insol = [W] f_akbJ :: t_akbI[tau:3] (CHoleCan: f)}\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15007Don't keep shadowed variables in ghci, both renamer and type checker2021-10-07T13:16:12ZTao Hesighingnow@gmail.comDon't keep shadowed variables in ghci, both renamer and type checkerIn #14052, we reverted [D2447](https://phabricator.haskell.org/D2447), then #11547 exists in HEAD again. In [ticket:14052\#comment:151549](https://gitlab.haskell.org//ghc/ghc/issues/14052#note_151549) and [ticket:14052\#comment:140478](h...In #14052, we reverted [D2447](https://phabricator.haskell.org/D2447), then #11547 exists in HEAD again. In [ticket:14052\#comment:151549](https://gitlab.haskell.org//ghc/ghc/issues/14052#note_151549) and [ticket:14052\#comment:140478](https://gitlab.haskell.org//ghc/ghc/issues/14052#note_140478), we decide that shadowed variables shouldn't be keep at all. This ticket is created to track the idea.
The same error of #11547 was also reported in [ticket:14996\#comment:151477](https://gitlab.haskell.org//ghc/ghc/issues/14996#note_151477),
> ```
> $ inplace/bin/ghc-stage2 --interactive
> GHCi, version 8.5.20180403: http://www.haskell.org/ghc/ :? for help
> Prelude> 1
> 1
> Prelude> 1
> 1
> Prelude> _
>
> <interactive>:1:1: error:
> GHC internal error: ‘Ghci1.it’ is not in scope during type > checking, but it passed the renamer
> tcl_env of environment: []
> ```
>
> (giving "1" twice is needed to reproduce the error)
NB: input "1" twice to create shadowed context is necessary to reproduce this bug.8.6.1Tao Hesighingnow@gmail.comTao Hesighingnow@gmail.com