GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:33:09Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/10897Incorrect ASSERT for buildPatSyn2019-07-07T18:33:09ZEdward Z. YangIncorrect ASSERT for buildPatSynConsider the following two files:
```
-- A.hs
{-# LANGUAGE PatternSynonyms #-}
module A where
pattern Single :: a -> a
pattern Single x = x
-- B.hs
module B where
import A
Single y = True
```
When I build these using one-shot compilat...Consider the following two files:
```
-- A.hs
{-# LANGUAGE PatternSynonyms #-}
module A where
pattern Single :: a -> a
pattern Single x = x
-- B.hs
module B where
import A
Single y = True
```
When I build these using one-shot compilation using a debugged GHC (i.e. with ASSERTs) I get the following error:
```
[ezyang@hs01 ghc-quick3]$ inplace/bin/ghc-stage2 -c A.hs -fforce-recomp
[ezyang@hs01 ghc-quick3]$ inplace/bin/ghc-stage2 -c B.hs -fforce-recomp
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150918 for x86_64-unknown-linux):
ASSERT failed! file compiler/iface/BuildTyCl.hs, line 210
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
I expanded the assert and discovered it was claiming the universal type variables of the matcher should be equal to the type variables of the pattern declaration. This assert cannot possibly be right: the matcher and the pattern declaration are typechecked separately and there's no reason that the local binders should actually be the same. The equality test here should be done up to alpha-renaming.
The other thing I found a bit puzzling was whether or not it mattered whether or not we used the local type variables from the matcher or the freshly bound ones. I suppose if we are consistent it shouldn't matter, so I don't think the code is buggy, just a bad ASSERT.
BTW: this assert problem doesn't show up with `--make` because the assert occurs during typechecking of interface files, and with `--make` we don't need to typecheck an interface file.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| 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":"Incorrect ASSERT for buildPatSyn","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"cactus"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following two files:\r\n\r\n{{{\r\n-- A.hs\r\n{-# LANGUAGE PatternSynonyms #-}\r\nmodule A where\r\npattern Single :: a -> a\r\npattern Single x = x\r\n\r\n-- B.hs\r\nmodule B where\r\nimport A\r\nSingle y = True\r\n}}}\r\n\r\nWhen I build these using one-shot compilation using a debugged GHC (i.e. with ASSERTs) I get the following error:\r\n\r\n{{{\r\n[ezyang@hs01 ghc-quick3]$ inplace/bin/ghc-stage2 -c A.hs -fforce-recomp \r\n[ezyang@hs01 ghc-quick3]$ inplace/bin/ghc-stage2 -c B.hs -fforce-recomp \r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 7.11.20150918 for x86_64-unknown-linux):\r\n ASSERT failed! file compiler/iface/BuildTyCl.hs, line 210\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nI expanded the assert and discovered it was claiming the universal type variables of the matcher should be equal to the type variables of the pattern declaration. This assert cannot possibly be right: the matcher and the pattern declaration are typechecked separately and there's no reason that the local binders should actually be the same. The equality test here should be done up to alpha-renaming.\r\n\r\nThe other thing I found a bit puzzling was whether or not it mattered whether or not we used the local type variables from the matcher or the freshly bound ones. I suppose if we are consistent it shouldn't matter, so I don't think the code is buggy, just a bad ASSERT.\r\n\r\nBTW: this assert problem doesn't show up with `--make` because the assert occurs during typechecking of interface files, and with `--make` we don't need to typecheck an interface file.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Gergő ÉrdiGergő Érdihttps://gitlab.haskell.org/ghc/ghc/-/issues/10896BadSock triggers failing ASSERT2019-07-07T18:33:09ZEdward Z. YangBadSock triggers failing ASSERT```
--- ./indexed-types/should_fail/BadSock.stderr.normalised 2015-09-18 20:44:48.437390831 +0000
+++ ./indexed-types/should_fail/BadSock.comp.stderr.normalised 2015-09-18 20:44:48.437390831 +0000
@@ -1,5 +1,5 @@
+ghc: panic! (the 'impos...```
--- ./indexed-types/should_fail/BadSock.stderr.normalised 2015-09-18 20:44:48.437390831 +0000
+++ ./indexed-types/should_fail/BadSock.comp.stderr.normalised 2015-09-18 20:44:48.437390831 +0000
@@ -1,5 +1,5 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 7.11.20150918 for x86_64-unknown-linux):
+ ASSERT failed! file compiler/typecheck/TcFlatten.hs, line 1041
-BadSock.hs:30:5:
- The type family ‘Readable’ should have 1 argument, but has been given none
- In the equations for closed type family ‘Foo’
- In the type family declaration for ‘Foo’
\ No newline at end of file
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
\ No newline at end of file
*** unexpected failure for BadSock(normal)
```
Haven't investigated any further.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"BadSock triggers failing ASSERT","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"{{{\r\n--- ./indexed-types/should_fail/BadSock.stderr.normalised\t2015-09-18 20:44:48.437390831 +0000\r\n+++ ./indexed-types/should_fail/BadSock.comp.stderr.normalised\t2015-09-18 20:44:48.437390831 +0000\r\n@@ -1,5 +1,5 @@\r\n+ghc: panic! (the 'impossible' happened)\r\n+ (GHC version 7.11.20150918 for x86_64-unknown-linux):\r\n+\tASSERT failed! file compiler/typecheck/TcFlatten.hs, line 1041\r\n \r\n-BadSock.hs:30:5:\r\n- The type family ‘Readable’ should have 1 argument, but has been given none\r\n- In the equations for closed type family ‘Foo’\r\n- In the type family declaration for ‘Foo’\r\n\\ No newline at end of file\r\n+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\\ No newline at end of file\r\n*** unexpected failure for BadSock(normal)\r\n}}}\r\n\r\nHaven't investigated any further.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10876stack overflow regression2019-07-07T18:33:20Zdmwitstack overflow regressionI would like to teach GHC that `<=` is transitive. I tried a module that looks like this:
```hs
{-# LANGUAGE GADTs, Rank2Types, TypeOperators #-}
import GHC.TypeLits
trans :: (a <= b, b <= c) => ((a <= c) => d) -> d
trans = undefined
``...I would like to teach GHC that `<=` is transitive. I tried a module that looks like this:
```hs
{-# LANGUAGE GADTs, Rank2Types, TypeOperators #-}
import GHC.TypeLits
trans :: (a <= b, b <= c) => ((a <= c) => d) -> d
trans = undefined
```
In 7.8, this is a type error; in 7.10 the compiler thinks a long time before emitting a stack overflow exception.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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":"stack overflow regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I would like to teach GHC that `<=` is transitive. I tried a module that looks like this:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs, Rank2Types, TypeOperators #-}\r\nimport GHC.TypeLits\r\ntrans :: (a <= b, b <= c) => ((a <= c) => d) -> d\r\ntrans = undefined\r\n}}}\r\n\r\nIn 7.8, this is a type error; in 7.10 the compiler thinks a long time before emitting a stack overflow exception.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10873Bad error message for incorrect pattern synonym signature2019-07-07T18:33:24ZMatthew PickeringBad error message for incorrect pattern synonym signatureConsider the following program
```
{-# LANGUAGE PatternSynonyms #-}
pattern Pat :: () => Show a => a -> Maybe a
pattern Pat a = Just a
```
GHC complains that
```
test.hs:4:9: No instance for (Show a) arising from a pattern
```
I thi...Consider the following program
```
{-# LANGUAGE PatternSynonyms #-}
pattern Pat :: () => Show a => a -> Maybe a
pattern Pat a = Just a
```
GHC complains that
```
test.hs:4:9: No instance for (Show a) arising from a pattern
```
I think this is quite difficult to understand. The problem is that matching on `Just a` doesn't provide the show constraint (it provides no constraints). A better error message here would explain this fact and maybe a short explanation of the difference between prov/req in a pattern synonym signature.8.0.1rdragonrdragonhttps://gitlab.haskell.org/ghc/ghc/-/issues/10849Injective type families broke debug build2019-07-07T18:33:30ZJoachim Breitnermail@joachim-breitner.deInjective type families broke debug buildHi,
since changeset:3744578 Travis observes these failures when built with DEBUG on:
```
Compile failed (status 256) errors were:
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150903 for x86_64-unknown-linux):
A...Hi,
since changeset:3744578 Travis observes these failures when built with DEBUG on:
```
Compile failed (status 256) errors were:
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150903 for x86_64-unknown-linux):
ASSERT failed! file compiler/typecheck/TcInteract.hs, line 1381
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T5490(normal)
Actual stderr output differs from expected:
--- ./indexed-types/should_fail/T5439.stderr.normalised 2015-09-03 04:54:51.184120403 +0000
+++ ./indexed-types/should_fail/T5439.comp.stderr.normalised 2015-09-03 04:54:51.184120403 +0000
@@ -1,25 +1,5 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 7.11.20150903 for x86_64-unknown-linux):
+ ASSERT failed! file compiler/typecheck/TcInteract.hs, line 1381
-T5439.hs:82:28:
- Couldn't match type ‘Attempt (HElemOf rs)’
- with ‘Attempt (HHead (HDrop n0 l0)) -> Attempt (HElemOf l0)’
- Expected type: f (Attempt (HNth n0 l0) -> Attempt (HElemOf l0))
- Actual type: f (Attempt (WaitOpResult (WaitOps rs)))
- Relevant bindings include
- register :: Bool -> Peano n -> WaitOps (HDrop n rs) -> IO Bool
- (bound at T5439.hs:64:9)
- ev :: f (Attempt (WaitOpResult (WaitOps rs)))
- (bound at T5439.hs:61:22)
- ops :: WaitOps rs (bound at T5439.hs:61:18)
- registerWaitOp :: WaitOps rs
- -> f (Attempt (WaitOpResult (WaitOps rs))) -> IO Bool
- (bound at T5439.hs:61:3)
- In the first argument of ‘complete’, namely ‘ev’
- In the expression: complete ev
-
-T5439.hs:82:39:
- Couldn't match expected type ‘Peano n0’
- with actual type ‘Attempt α0’
- In the second argument of ‘($)’, namely
- ‘Failure (e :: SomeException)’
- In the second argument of ‘($)’, namely
- ‘inj $ Failure (e :: SomeException)’
\ No newline at end of file
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
\ No newline at end of file
*** unexpected failure for T5439(normal)
```
}}}
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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":"Injective type families broke debug build","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"jstolarek"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Hi,\r\n\r\nsince changeset:3744578 Travis observes these failures when built with DEBUG on:\r\n{{{\r\nCompile failed (status 256) errors were:\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 7.11.20150903 for x86_64-unknown-linux):\r\n\tASSERT failed! file compiler/typecheck/TcInteract.hs, line 1381\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n\r\n*** unexpected failure for T5490(normal)\r\n\r\nActual stderr output differs from expected:\r\n--- ./indexed-types/should_fail/T5439.stderr.normalised\t2015-09-03 04:54:51.184120403 +0000\r\n+++ ./indexed-types/should_fail/T5439.comp.stderr.normalised\t2015-09-03 04:54:51.184120403 +0000\r\n@@ -1,25 +1,5 @@\r\n+ghc: panic! (the 'impossible' happened)\r\n+ (GHC version 7.11.20150903 for x86_64-unknown-linux):\r\n+\tASSERT failed! file compiler/typecheck/TcInteract.hs, line 1381\r\n \r\n-T5439.hs:82:28:\r\n- Couldn't match type ‘Attempt (HElemOf rs)’\r\n- with ‘Attempt (HHead (HDrop n0 l0)) -> Attempt (HElemOf l0)’\r\n- Expected type: f (Attempt (HNth n0 l0) -> Attempt (HElemOf l0))\r\n- Actual type: f (Attempt (WaitOpResult (WaitOps rs)))\r\n- Relevant bindings include\r\n- register :: Bool -> Peano n -> WaitOps (HDrop n rs) -> IO Bool\r\n- (bound at T5439.hs:64:9)\r\n- ev :: f (Attempt (WaitOpResult (WaitOps rs)))\r\n- (bound at T5439.hs:61:22)\r\n- ops :: WaitOps rs (bound at T5439.hs:61:18)\r\n- registerWaitOp :: WaitOps rs\r\n- -> f (Attempt (WaitOpResult (WaitOps rs))) -> IO Bool\r\n- (bound at T5439.hs:61:3)\r\n- In the first argument of ‘complete’, namely ‘ev’\r\n- In the expression: complete ev\r\n-\r\n-T5439.hs:82:39:\r\n- Couldn't match expected type ‘Peano n0’\r\n- with actual type ‘Attempt α0’\r\n- In the second argument of ‘($)’, namely\r\n- ‘Failure (e :: SomeException)’\r\n- In the second argument of ‘($)’, namely\r\n- ‘inj $ Failure (e :: SomeException)’\r\n\\ No newline at end of file\r\n+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\\ No newline at end of file\r\n*** unexpected failure for T5439(normal)\r\n}}}\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Jan Stolarekjan.stolarek@ed.ac.ukJan Stolarekjan.stolarek@ed.ac.ukhttps://gitlab.haskell.org/ghc/ghc/-/issues/10831Document conditions on deriving Functor2019-07-07T18:33:39ZhtebalakaDocument conditions on deriving FunctorGHC can derive Functor for Okay, but rejects the equivalent Bad.
```hs
{-# LANGUAGE DeriveFunctor #-}
data Okay f g a b = Inl (f a b) | Inr (g a b) deriv...GHC can derive Functor for Okay, but rejects the equivalent Bad.
```hs
{-# LANGUAGE DeriveFunctor #-}
data Okay f g a b = Inl (f a b) | Inr (g a b) deriving (Functor)
newtype Bad f g a b = Bad (Either (f a b) (g a b)) deriving (Functor)
```
```
Can't make a derived instance of ‘Functor (Bad f g a)’:
Constructor ‘Bad’ must use the type variable only as the last argument of a data type
In the data declaration for ‘Bad’
```8.0.1Ryan ScottRyan Scotthttps://gitlab.haskell.org/ghc/ghc/-/issues/10815Need more kind inference in associated type instances2019-07-07T18:33:45ZRichard Eisenbergrae@richarde.devNeed more kind inference in associated type instancesWhen I say
```
{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-}
module Bug where
import Data.Proxy
class kproxy ~ 'KProxy => C (kproxy :: KProxy k) where
type F (a :: k)
instance C ('KProxy :: KProxy Bool) where
type F a = In...When I say
```
{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-}
module Bug where
import Data.Proxy
class kproxy ~ 'KProxy => C (kproxy :: KProxy k) where
type F (a :: k)
instance C ('KProxy :: KProxy Bool) where
type F a = Int
```
I get
```
Type indexes must match class instance head
Found ‘k’ but expected ‘Bool’
In the type instance declaration for ‘F’
In the instance declaration for ‘C (KProxy :: KProxy Bool)’
```
But the kind of `a` should really be known to be `Bool`.
This ticket is broken out from [ticket:9063\#comment:82569](https://gitlab.haskell.org//ghc/ghc/issues/9063#note_82569), which was evidently not addressed when fixing that ticket.
Patch coming soon.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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":"Need more kind inference in associated type instances","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When I say\r\n\r\n{{{\r\n{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-}\r\n\r\nmodule Bug where\r\n\r\nimport Data.Proxy\r\n\r\nclass kproxy ~ 'KProxy => C (kproxy :: KProxy k) where\r\n type F (a :: k)\r\n\r\ninstance C ('KProxy :: KProxy Bool) where\r\n type F a = Int\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\n Type indexes must match class instance head\r\n Found ‘k’ but expected ‘Bool’\r\n In the type instance declaration for ‘F’\r\n In the instance declaration for ‘C (KProxy :: KProxy Bool)’\r\n}}}\r\n\r\nBut the kind of `a` should really be known to be `Bool`.\r\n\r\nThis ticket is broken out from comment:3:ticket:9063, which was evidently not addressed when fixing that ticket.\r\n\r\nPatch coming soon.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/10806Type error and type level (<=) together cause GHC to hang2019-07-07T18:33:47ZhtebalakaType error and type level (<=) together cause GHC to hangThe following incorrect arity triggers an infinite loop at compile time. The issue is somehow related to the use of (\<=) in constraints of the Q data constructor; if I remove either of the constraints or add an (a \<= c) constraint it w...The following incorrect arity triggers an infinite loop at compile time. The issue is somehow related to the use of (\<=) in constraints of the Q data constructor; if I remove either of the constraints or add an (a \<= c) constraint it works as you would expect.
```hs
{-# LANGUAGE GADTs, ExplicitNamespaces, TypeOperators, DataKinds #-}
import GHC.TypeLits (Nat, type (<=))
data Q a where
Q :: (a <= b, b <= c) => proxy a -> proxy b -> Q c
triggersLoop :: Q b -> Q b -> Bool
triggersLoop (Q _ _) (Q _ _) = print 'x' 'y'
```
Incorrect function definitions, like `foo :: a -> a ; foo _ x = x` also result in an infinite loop.8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10805Could not deduce (a ~ b) implies (f a ~ f b), because a type function may not...2019-07-07T18:33:48ZhtebalakaCould not deduce (a ~ b) implies (f a ~ f b), because a type function may not be injectiveI don't know if the summary I provided is what's really going on here, but I'm a little baffled why this doesn't typecheck. I can't see what injectivity has to do with it, since we're not trying to deduce that the arguments are the same ...I don't know if the summary I provided is what's really going on here, but I'm a little baffled why this doesn't typecheck. I can't see what injectivity has to do with it, since we're not trying to deduce that the arguments are the same from the result of an application being the same; rather we're doing the opposite. I've encountered plenty of obvious arithmetic laws that I've needed to unsafeCoerceConstraint away with doing type level arithmetic, but this seems like it should be trivial regardless.
```hs
{-# LANGUAGE GADTs, ExplicitNamespaces, TypeOperators, DataKinds #-}
{-# LANGUAGE ConstraintKinds, KindSignatures, PatternGuards #-}
import Data.Type.Equality ((:~:)(..))
import GHC.TypeLits (Nat, type (<=), type (-), type (+), type (<=?))
data SNat :: Nat -> * where
SSucc :: SNat a -> SNat (a + 1)
SZero :: SNat 0
heqHet :: SNat a -> SNat b -> Maybe (a :~: b)
heqHet SZero SZero = Just Refl
heqHet (SSucc a) (SSucc b)
| Just Refl <- heqHet a b = Just Refl
heqHet _ _ = Nothing
data Slice :: Nat -> Nat -> * where
Slice :: ((start + 1) <= end, end <= numElements)
=> SNat numElements -> SNat start -> SNat end
-> Slice numElements (end - start)
heqHet' :: Slice a b -> Slice a b' -> Bool
heqHet' (Slice _ start end) (Slice _ start' end')
| Just _ <- heqHet start start'
, Just _ <- heqHet end end' = True
| otherwise = False
```
```hs
Slice.hs:24:10:
Could not deduce (((start + 1) <=? a) ~ ((start + 1) <=? a))
from the context (b ~ (end - start), (start + 1) <= end, end <= a)
bound by a pattern with constructor
Slice :: forall (numElements :: Nat) (start :: Nat) (end :: Nat).
((start + 1) <= end, end <= numElements) =>
SNat numElements
-> SNat start -> SNat end -> Slice numElements (end - start),
in an equation for ‘heqHet'’
at Slice.hs:24:10-26
or from (b' ~ (end1 - start1), (start1 + 1) <= end1, end1 <= a)
bound by a pattern with constructor
Slice :: forall (numElements :: Nat) (start :: Nat) (end :: Nat).
((start + 1) <= end, end <= numElements) =>
SNat numElements
-> SNat start -> SNat end -> Slice numElements (end - start),
in an equation for ‘heqHet'’
at Slice.hs:24:30-48
NB: ‘GHC.TypeLits.<=?’ is a type function, and may not be injective
Relevant bindings include
heqHet' :: Slice a b -> Slice a b' -> Bool (bound at Slice.hs:24:1)
In the pattern: Slice _ start end
In an equation for ‘heqHet'’:
heqHet' (Slice _ start end) (Slice _ start' end')
| Just _ <- heqHet start start', Just _ <- heqHet end end' = True
| otherwise = False
Failed, modules loaded: none.
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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":"Could not deduce (a ~ b) implies (f a ~ f b), because a type function may not be injective","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I don't know if the summary I provided is what's really going on here, but I'm a little baffled why this doesn't typecheck. I can't see what injectivity has to do with it, since we're not trying to deduce that the arguments are the same from the result of an application being the same; rather we're doing the opposite. I've encountered plenty of obvious arithmetic laws that I've needed to unsafeCoerceConstraint away with doing type level arithmetic, but this seems like it should be trivial regardless.\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs, ExplicitNamespaces, TypeOperators, DataKinds #-}\r\n{-# LANGUAGE ConstraintKinds, KindSignatures, PatternGuards #-}\r\n\r\nimport Data.Type.Equality ((:~:)(..))\r\nimport GHC.TypeLits (Nat, type (<=), type (-), type (+), type (<=?))\r\n\r\ndata SNat :: Nat -> * where\r\n SSucc :: SNat a -> SNat (a + 1)\r\n SZero :: SNat 0\r\n\r\nheqHet :: SNat a -> SNat b -> Maybe (a :~: b)\r\nheqHet SZero SZero = Just Refl\r\nheqHet (SSucc a) (SSucc b)\r\n | Just Refl <- heqHet a b = Just Refl\r\nheqHet _ _ = Nothing\r\n\r\ndata Slice :: Nat -> Nat -> * where\r\n Slice :: ((start + 1) <= end, end <= numElements)\r\n => SNat numElements -> SNat start -> SNat end\r\n -> Slice numElements (end - start)\r\n\r\nheqHet' :: Slice a b -> Slice a b' -> Bool\r\nheqHet' (Slice _ start end) (Slice _ start' end')\r\n | Just _ <- heqHet start start'\r\n , Just _ <- heqHet end end' = True\r\n | otherwise = False\r\n}}}\r\n\r\n\r\n{{{#!hs\r\nSlice.hs:24:10:\r\n Could not deduce (((start + 1) <=? a) ~ ((start + 1) <=? a))\r\n from the context (b ~ (end - start), (start + 1) <= end, end <= a)\r\n bound by a pattern with constructor\r\n Slice :: forall (numElements :: Nat) (start :: Nat) (end :: Nat).\r\n ((start + 1) <= end, end <= numElements) =>\r\n SNat numElements\r\n -> SNat start -> SNat end -> Slice numElements (end - start),\r\n in an equation for ‘heqHet'’\r\n at Slice.hs:24:10-26\r\n or from (b' ~ (end1 - start1), (start1 + 1) <= end1, end1 <= a)\r\n bound by a pattern with constructor\r\n Slice :: forall (numElements :: Nat) (start :: Nat) (end :: Nat).\r\n ((start + 1) <= end, end <= numElements) =>\r\n SNat numElements\r\n -> SNat start -> SNat end -> Slice numElements (end - start),\r\n in an equation for ‘heqHet'’\r\n at Slice.hs:24:30-48\r\n NB: ‘GHC.TypeLits.<=?’ is a type function, and may not be injective\r\n Relevant bindings include\r\n heqHet' :: Slice a b -> Slice a b' -> Bool (bound at Slice.hs:24:1)\r\n In the pattern: Slice _ start end\r\n In an equation for ‘heqHet'’:\r\n heqHet' (Slice _ start end) (Slice _ start' end')\r\n | Just _ <- heqHet start start', Just _ <- heqHet end end' = True\r\n | otherwise = False\r\nFailed, modules loaded: none.\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10753Type checker fails to recognize equality2019-07-07T18:34:11ZljliType checker fails to recognize equality```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
module Test where
import qualified Control.Monad.State as S
class HasConns (m :: * -> *) where
type Conn m
foo :: (HasConns m, Monad m) => S.StateT (Conn m) m ()
...```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
module Test where
import qualified Control.Monad.State as S
class HasConns (m :: * -> *) where
type Conn m
foo :: (HasConns m, Monad m) => S.StateT (Conn m) m ()
foo =
do _ <- S.get
return ()
```
This fails to compile with GHC 7.10.2:
```
Could not deduce (S.MonadState (Conn m) (S.StateT (Conn m) m))
arising from a use of ‘S.get’
from the context (HasConns m, Monad m)
bound by the type signature for
foo :: (HasConns m, Monad m) => S.StateT (Conn m) m ()
```
It compiles with GHC 7.8.4, though.
Adding "Conn m \~ Conn m" to the type context of foo lets it compile again.
This seems not right to me.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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 checker fails to recognize equality","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE KindSignatures #-}\r\nmodule Test where\r\n\r\nimport qualified Control.Monad.State as S\r\n\r\nclass HasConns (m :: * -> *) where\r\n type Conn m\r\n\r\nfoo :: (HasConns m, Monad m) => S.StateT (Conn m) m ()\r\nfoo =\r\n do _ <- S.get\r\n return ()\r\n}}}\r\n\r\nThis fails to compile with GHC 7.10.2:\r\n\r\n{{{\r\n Could not deduce (S.MonadState (Conn m) (S.StateT (Conn m) m))\r\n arising from a use of ‘S.get’\r\n from the context (HasConns m, Monad m)\r\n bound by the type signature for\r\n foo :: (HasConns m, Monad m) => S.StateT (Conn m) m ()\r\n}}}\r\n\r\nIt compiles with GHC 7.8.4, though.\r\nAdding \"Conn m ~ Conn m\" to the type context of foo lets it compile again.\r\nThis seems not right to me.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10742GHC cannot deduce (irrelevant) reflexive type equality.2019-07-07T18:34:14ZNathan CollinsGHC cannot deduce (irrelevant) reflexive type equality.GHC is creating an irrelevant reflexive type equality and then failing to deduce it. The problem seems to be related to transitivity for `GHC.TypeLits.Nat`, as the example will make clear.
Example:
```hs
{-# LANGUAGE GADTs #-}
{-# LANG...GHC is creating an irrelevant reflexive type equality and then failing to deduce it. The problem seems to be related to transitivity for `GHC.TypeLits.Nat`, as the example will make clear.
Example:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module TypeLitsBug where
import GHC.TypeLits
data T a where MkT :: T Int
test :: ((x <=? y) ~ 'True, (y <=? z) ~ 'True)
=> proxy x y z -> ()
test _ = case MkT of MkT -> ()
```
Error message:
```
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.2
$ ghc -c TypeLitsBug.hs
TypeLitsBug.hs:11:9:
Could not deduce ((x <=? z) ~ (x <=? z))
from the context ((x <=? y) ~ 'True, (y <=? z) ~ 'True)
bound by the type signature for
test :: ((x <=? y) ~ 'True, (y <=? z) ~ 'True) => proxy x y z -> ()
at TypeLitsBug.hs:(11,9)-(12,25)
NB: ‘<=?’ is a type function, and may not be injective
```
Notice the `x <=? z` relating `x` to `z`. I only mention `x <=? y` and `y <=? z` in the program, so it seems transitivity of `<=` is implicitly involved. Also, the problem goes away if I remove the GADT pattern match.
I asked Iavor about this and he suspected the ambiguity check.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"GHC cannot deduce (irrelevant) reflexive type equality.","status":"New","operating_system":"Linux","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.2","keywords":["GADTs","TypeLits"],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"GHC is creating an irrelevant reflexive type equality and then failing to deduce it. The problem seems to be related to transitivity for `GHC.TypeLits.Nat`, as the example will make clear.\r\n\r\nExample:\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE DataKinds #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n\r\nmodule TypeLitsBug where\r\n\r\nimport GHC.TypeLits\r\n\r\ndata T a where MkT :: T Int\r\n\r\ntest :: ((x <=? y) ~ 'True, (y <=? z) ~ 'True)\r\n => proxy x y z -> ()\r\ntest _ = case MkT of MkT -> ()\r\n}}}\r\n\r\nError message:\r\n{{{\r\n$ ghc --version\r\nThe Glorious Glasgow Haskell Compilation System, version 7.10.2\r\n\r\n$ ghc -c TypeLitsBug.hs \r\n\r\nTypeLitsBug.hs:11:9:\r\n Could not deduce ((x <=? z) ~ (x <=? z))\r\n from the context ((x <=? y) ~ 'True, (y <=? z) ~ 'True)\r\n bound by the type signature for\r\n test :: ((x <=? y) ~ 'True, (y <=? z) ~ 'True) => proxy x y z -> ()\r\n at TypeLitsBug.hs:(11,9)-(12,25)\r\n NB: ‘<=?’ is a type function, and may not be injective\r\n}}}\r\n\r\nNotice the `x <=? z` relating `x` to `z`. I only mention `x <=? y` and `y <=? z` in the program, so it seems transitivity of `<=` is implicitly involved. Also, the problem goes away if I remove the GADT pattern match.\r\n\r\nI asked Iavor about this and he suspected the ambiguity check.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10625Spurious unused quantified type variable warning with ExistentialQuantification2019-07-07T18:34:58ZRyan ScottSpurious unused quantified type variable warning with ExistentialQuantificationWhen using an existentially quantified type variable that shadows another variable in a data declaration, `-Wall` produces more warnings than necessary:
```
$ ghci -XExistentialQuantification -Wall
GHCi, version 7.10.1: http://www.haske...When using an existentially quantified type variable that shadows another variable in a data declaration, `-Wall` produces more warnings than necessary:
```
$ ghci -XExistentialQuantification -Wall
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
λ> data Ex a = forall a. Ex a
<interactive>:2:20: Warning:
Unused quantified type variable ‘a’
In the definition of data constructor ‘Ex’
<interactive>:2:20: Warning:
This binding for ‘a’ shadows the existing binding
bound at <interactive>:2:9
```
The unused quantified type variable warning seems wrong, since it *is* being used (as the shadowing warning indicates). Curiously, this warning doesn't seem to appear when doing something similar with `RankNTypes`:
```
$ ghci -XRankNTypes -Wall
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
λ> data Ex a = Ex (forall a. a)
<interactive>:2:24: Warning:
This binding for ‘a’ shadows the existing binding
bound at <interactive>:2:9
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.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":"Spurious unused quantified type variable warning with ExistentialQuantification","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When using an existentially quantified type variable that shadows another variable in a data declaration, {{{-Wall}}} produces more warnings than necessary:\r\n\r\n{{{\r\n$ ghci -XExistentialQuantification -Wall\r\nGHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help\r\nλ> data Ex a = forall a. Ex a\r\n\r\n<interactive>:2:20: Warning:\r\n Unused quantified type variable ‘a’\r\n In the definition of data constructor ‘Ex’\r\n\r\n<interactive>:2:20: Warning:\r\n This binding for ‘a’ shadows the existing binding\r\n bound at <interactive>:2:9\r\n}}}\r\n\r\nThe unused quantified type variable warning seems wrong, since it ''is'' being used (as the shadowing warning indicates). Curiously, this warning doesn't seem to appear when doing something similar with {{{RankNTypes}}}:\r\n\r\n{{{\r\n$ ghci -XRankNTypes -Wall\r\nGHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help\r\nλ> data Ex a = Ex (forall a. a)\r\n\r\n<interactive>:2:24: Warning:\r\n This binding for ‘a’ shadows the existing binding\r\n bound at <interactive>:2:9\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10618HEAD@d71b65f53a panics: ``get_op (--$)''2019-07-07T18:35:00ZBen PriceHEAD@d71b65f53a panics: ``get_op (--$)''(Note that 7.10.1 works as expected)
This one line generates a panic:
```hs
panic = GarbageConstructorName $ a --$ b
```
(in an otherwise blank file, when passed to `ghc ` or `ghci`. Just the right hand side panics `ghci` interactivel...(Note that 7.10.1 works as expected)
This one line generates a panic:
```hs
panic = GarbageConstructorName $ a --$ b
```
(in an otherwise blank file, when passed to `ghc ` or `ghci`. Just the right hand side panics `ghci` interactively.)
Error message:
```
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150708 for x86_64-unknown-linux):
get_op (--$)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
`uname -a: Linux cam-05-unx 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul 15 04:02:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux`
```
gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
```
With `ghc -v` (Was built with `BuildFlavour = devel2`, default `build.mk` otherwise):
```
Glasgow Haskell Compiler, Version 7.11.20150708, stage 2 booted by GHC version 7.8.2
Using binary package database: /5playpen/t-bepric/ghc-build/inplace/lib/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.4.0.0-inplace
wired-in package integer-gmp mapped to integer-gmp-1.0.0.0-inplace
wired-in package base mapped to base-4.8.2.0-inplace
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.10.0.0-inplace
wired-in package ghc mapped to ghc-7.11.20150708-inplace
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
wired-in package ghc-prim mapped to ghc-prim-0.4.0.0-inplace
wired-in package integer-gmp mapped to integer-gmp-1.0.0.0-inplace
wired-in package base mapped to base-4.8.2.0-inplace
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.10.0.0-inplace
wired-in package ghc mapped to ghc-7.11.20150708-inplace
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *GetOpCrash.hs
Stable obj: []
Stable BCO: []
Ready for upsweep
[NONREC
ModSummary {
ms_hs_date = 2015-07-08 15:09:13 UTC
ms_mod = Main,
ms_textual_imps = [import (implicit) Prelude]
ms_srcimps = []
}]
*** Deleting temp files:
Deleting:
compile: input file GetOpCrash.hs
Created temporary directory: /tmp/ghc22576_0
*** Checking old interface for Main:
[1 of 1] Compiling Main ( GetOpCrash.hs, GetOpCrash.o )
*** Parser:
*** Renamer/typechecker:
*** Deleting temp files:
Deleting: /tmp/ghc22576_0/ghc_1.s
Warning: deleting non-existent /tmp/ghc22576_0/ghc_1.s
*** Deleting temp dirs:
Deleting: /tmp/ghc22576_0
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150708 for x86_64-unknown-linux):
get_op (--$)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"HEAD@d71b65f53a panics: ``get_op (--$)''","status":"New","operating_system":"Linux","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"(Note that 7.10.1 works as expected)\r\n\r\nThis one line generates a panic:\r\n{{{#!hs\r\npanic = GarbageConstructorName $ a --$ b\r\n}}}\r\n(in an otherwise blank file, when passed to {{{ghc }}} or {{{ghci}}}. Just the right hand side panics {{{ghci}}} interactively.)\r\n\r\nError message:\r\n{{{\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 7.11.20150708 for x86_64-unknown-linux):\r\n get_op (--$)\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\n{{{uname -a: Linux cam-05-unx 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul 15 04:02:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux}}}\r\n{{{\r\ngcc -v:\r\nUsing built-in specs.\r\nCOLLECT_GCC=gcc\r\nCOLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper\r\nTarget: x86_64-linux-gnu\r\nConfigured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu\r\nThread model: posix\r\ngcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)\r\n}}}\r\n\r\nWith {{{ghc -v}}} (Was built with {{{BuildFlavour = devel2}}}, default {{{build.mk}}} otherwise):\r\n{{{\r\nGlasgow Haskell Compiler, Version 7.11.20150708, stage 2 booted by GHC version 7.8.2\r\nUsing binary package database: /5playpen/t-bepric/ghc-build/inplace/lib/package.conf.d/package.cache\r\nwired-in package ghc-prim mapped to ghc-prim-0.4.0.0-inplace\r\nwired-in package integer-gmp mapped to integer-gmp-1.0.0.0-inplace\r\nwired-in package base mapped to base-4.8.2.0-inplace\r\nwired-in package rts mapped to builtin_rts\r\nwired-in package template-haskell mapped to template-haskell-2.10.0.0-inplace\r\nwired-in package ghc mapped to ghc-7.11.20150708-inplace\r\nwired-in package dph-seq not found.\r\nwired-in package dph-par not found.\r\nHsc static flags: \r\nwired-in package ghc-prim mapped to ghc-prim-0.4.0.0-inplace\r\nwired-in package integer-gmp mapped to integer-gmp-1.0.0.0-inplace\r\nwired-in package base mapped to base-4.8.2.0-inplace\r\nwired-in package rts mapped to builtin_rts\r\nwired-in package template-haskell mapped to template-haskell-2.10.0.0-inplace\r\nwired-in package ghc mapped to ghc-7.11.20150708-inplace\r\nwired-in package dph-seq not found.\r\nwired-in package dph-par not found.\r\n*** Chasing dependencies:\r\nChasing modules from: *GetOpCrash.hs\r\nStable obj: []\r\nStable BCO: []\r\nReady for upsweep\r\n [NONREC\r\n ModSummary {\r\n ms_hs_date = 2015-07-08 15:09:13 UTC\r\n ms_mod = Main,\r\n ms_textual_imps = [import (implicit) Prelude]\r\n ms_srcimps = []\r\n }]\r\n*** Deleting temp files:\r\nDeleting: \r\ncompile: input file GetOpCrash.hs\r\nCreated temporary directory: /tmp/ghc22576_0\r\n*** Checking old interface for Main:\r\n[1 of 1] Compiling Main ( GetOpCrash.hs, GetOpCrash.o )\r\n*** Parser:\r\n*** Renamer/typechecker:\r\n*** Deleting temp files:\r\nDeleting: /tmp/ghc22576_0/ghc_1.s\r\nWarning: deleting non-existent /tmp/ghc22576_0/ghc_1.s\r\n*** Deleting temp dirs:\r\nDeleting: /tmp/ghc22576_0\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 7.11.20150708 for x86_64-unknown-linux):\r\n get_op (--$)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/10592Allow cycles in class declarations2019-07-07T18:35:06ZMikeIzbickiAllow cycles in class declarationsIn particular, I would like to have a class hierarchy that looks like:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
type family Scalar x
class Field (Scalar x) => Vector x
class Vector x => Field x
```
It is...In particular, I would like to have a class hierarchy that looks like:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
type family Scalar x
class Field (Scalar x) => Vector x
class Vector x => Field x
```
It is the case that every field is a vector, and the scalar associated with every vector is a field. But we can't currently enforce that.8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10589Core Lint error with LambdaCase2019-07-07T18:35:07ZRichard Eisenbergrae@richarde.devCore Lint error with LambdaCaseWhen I say
```
{-# LANGUAGE LambdaCase, TypeFamilies #-}
type family F a where
F a = Bool -> a
foo = (\case True -> 5
False -> 6) :: F Int
```
`-dcore-lint` tells me
```
*** Core Lint errors : in result of Desugar (af...When I say
```
{-# LANGUAGE LambdaCase, TypeFamilies #-}
type family F a where
F a = Bool -> a
foo = (\case True -> 5
False -> 6) :: F Int
```
`-dcore-lint` tells me
```
*** Core Lint errors : in result of Desugar (after optimization) ***
/Users/rae/temp/Bug.hs:6:1: Warning:
[RHS of foo :: Bool -> Int]
From-type of Cast differs from type of enclosed expression
...
```
The problem is a missing `mkTcSymCo` in the relevant bit of `tcExpr`.
Will fix in ongoing work.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.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":"Core Lint error with LambdaCase","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When I say\r\n\r\n{{{\r\n{-# LANGUAGE LambdaCase, TypeFamilies #-}\r\n\r\ntype family F a where\r\n F a = Bool -> a\r\n\r\nfoo = (\\case True -> 5\r\n False -> 6) :: F Int\r\n}}}\r\n\r\n`-dcore-lint` tells me\r\n\r\n{{{\r\n*** Core Lint errors : in result of Desugar (after optimization) ***\r\n/Users/rae/temp/Bug.hs:6:1: Warning:\r\n [RHS of foo :: Bool -> Int]\r\n From-type of Cast differs from type of enclosed expression\r\n...\r\n}}}\r\n\r\nThe problem is a missing `mkTcSymCo` in the relevant bit of `tcExpr`.\r\n\r\nWill fix in ongoing work.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/10533Assertion failure on FD3 test in TcErrors2019-07-07T18:35:27ZRichard Eisenbergrae@richarde.devAssertion failure on FD3 test in TcErrorsTest case `typecheck/should_compile/FD3` leads to an `ASSERT`ion error:
```
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150605 for x86_64-apple-darwin):
ASSERT failed!
file compiler/typecheck/TcErrors.hs line...Test case `typecheck/should_compile/FD3` leads to an `ASSERT`ion error:
```
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150605 for x86_64-apple-darwin):
ASSERT failed!
file compiler/typecheck/TcErrors.hs line 321
[[D] _ :: a_amP[sk] ~ (String, a_amP[sk]) (CNonCanonical)]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
FD3.log (attached) shows the error happening.
(When originally posting this ticket, I was very confused. The first several comments, through [ticket:10533\#comment:101025](https://gitlab.haskell.org//ghc/ghc/issues/10533#note_101025), are now bogus. Please ignore.)8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10461Suggest UnliftedFFITypes when applicable2019-07-07T18:35:49ZEdward Z. YangSuggest UnliftedFFITypes when applicableHere's an example bad error message:
```
Serum.hs:5:1:
Unacceptable result type in foreign declaration:
‘Word#’ cannot be marshalled in a foreign call
When checking declaration:
foreign import prim safe "static cheny...Here's an example bad error message:
```
Serum.hs:5:1:
Unacceptable result type in foreign declaration:
‘Word#’ cannot be marshalled in a foreign call
When checking declaration:
foreign import prim safe "static chenycopy" cheneycopy
:: Any -> Word#
```
We should also add something like:
```
To enable marshalling unlifted types, enable -XUnliftedFFITypes
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | low |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Suggest UnliftedFFITypes when applicable","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"ezyang"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's an example bad error message:\r\n\r\n{{{\r\nSerum.hs:5:1:\r\n Unacceptable result type in foreign declaration:\r\n ‘Word#’ cannot be marshalled in a foreign call\r\n When checking declaration:\r\n foreign import prim safe \"static chenycopy\" cheneycopy\r\n :: Any -> Word#\r\n\r\n}}}\r\n\r\nWe should also add something like:\r\n\r\n{{{\r\n To enable marshalling unlifted types, enable -XUnliftedFFITypes\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Edward Z. YangEdward Z. Yanghttps://gitlab.haskell.org/ghc/ghc/-/issues/10460Allow foreign prim to return Any2022-03-28T11:37:32ZEdward Z. YangAllow foreign prim to return AnyPresently, we have
```
{-# LANGUAGE GHCForeignImportPrim #-}
module Serum where
import GHC.Exts
foreign import prim "chenycopy" cheneycopy :: Any -> Any
```
induces the error
```
Serum.hs:5:1:
Unacceptable result type in foreign ...Presently, we have
```
{-# LANGUAGE GHCForeignImportPrim #-}
module Serum where
import GHC.Exts
foreign import prim "chenycopy" cheneycopy :: Any -> Any
```
induces the error
```
Serum.hs:5:1:
Unacceptable result type in foreign declaration:
‘Any’ cannot be marshalled in a foreign call
When checking declaration:
foreign import prim safe "static chenycopy" cheneycopy
:: Any -> Any
```
We ought to allow a lifted value to be returned from a foreign primop; no reason not to, anyway; no reason not to, and there are plenty of built-in primops which do this.
For reference, lifted arguments were allowed in arugments in this commit:
```
commit e29001c9e0f73885c0b85d86c3a854519448013a
Author: Joachim Breitner <mail@joachim-breitner.de> Mon Mar 12 01:20:12 2012
Committer: Simon Marlow <marlowsd@gmail.com> Wed Mar 14 06:01:18 2012
Allow Any as an argument type to foreign prim functions
```
I can volunteer to write the patch but it would be good if someone else OKs this before I proceed.8.0.1Edward Z. YangEdward Z. Yanghttps://gitlab.haskell.org/ghc/ghc/-/issues/10432panic with kind polymorphism2019-07-07T18:35:56ZAshley Yakeleypanic with kind polymorphism```hs
{-# LANGUAGE ExistentialQuantification, PolyKinds,
DataKinds, RankNTypes, GADTs, TypeOperators #-}
module Bug where
import Data.Type.Equality
data WrappedType = forall a. WrapType a;
matchReflK :: forall (a :: ka) (b :: kb) (r ::...```hs
{-# LANGUAGE ExistentialQuantification, PolyKinds,
DataKinds, RankNTypes, GADTs, TypeOperators #-}
module Bug where
import Data.Type.Equality
data WrappedType = forall a. WrapType a;
matchReflK :: forall (a :: ka) (b :: kb) (r :: *).
('WrapType a :~: 'WrapType b) -> (('WrapType a ~ 'WrapType b) => r) -> r;
matchReflK Refl r = r;
```
give this:
```
Bug.hs:8:15:
Couldn't match kind ‘ka’ with ‘kb’
‘ka’ is untouchable
inside the constraints ('WrapType a ~ 'WrapType b)
bound by the type signature for
matchReflK :: ('WrapType a ~ 'WrapType b) => r
at Bug.hs:(8,15)-(9,74)ghc: panic! (the 'impossible' happened)
(GHC version 7.10.1 for x86_64-unknown-linux):
No skolem info: ka_aqv[sk]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
I actually think GHC should accept this (and furthermore infer `ka ~ kb`).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.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":"panic with kind polymorphism","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{-# LANGUAGE ExistentialQuantification, PolyKinds,\r\nDataKinds, RankNTypes, GADTs, TypeOperators #-}\r\nmodule Bug where\r\nimport Data.Type.Equality\r\n\r\ndata WrappedType = forall a. WrapType a;\r\n\r\nmatchReflK :: forall (a :: ka) (b :: kb) (r :: *).\r\n ('WrapType a :~: 'WrapType b) -> (('WrapType a ~ 'WrapType b) => r) -> r;\r\nmatchReflK Refl r = r;\r\n}}}\r\n\r\ngive this:\r\n\r\n{{{\r\nBug.hs:8:15:\r\n Couldn't match kind ‘ka’ with ‘kb’\r\n ‘ka’ is untouchable\r\n inside the constraints ('WrapType a ~ 'WrapType b)\r\n bound by the type signature for\r\n matchReflK :: ('WrapType a ~ 'WrapType b) => r\r\n at Bug.hs:(8,15)-(9,74)ghc: panic! (the 'impossible' happened)\r\n (GHC version 7.10.1 for x86_64-unknown-linux):\r\n\tNo skolem info: ka_aqv[sk]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nI actually think GHC should accept this (and furthermore infer `ka ~ kb`).","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/10423Can't infer Monad n from (Monad m, m ~ n)2019-07-07T18:35:59ZFeuerbachCan't infer Monad n from (Monad m, m ~ n)This looks like a regression in GHC HEAD.
```
Test/SmallCheck/Property.hs:187:10:
Could not deduce (Monad n)
arising from the superclasses of an instance declaration
from the context: (Monad m, m ~ n)
bound by the in...This looks like a regression in GHC HEAD.
```
Test/SmallCheck/Property.hs:187:10:
Could not deduce (Monad n)
arising from the superclasses of an instance declaration
from the context: (Monad m, m ~ n)
bound by the instance declaration
at Test/SmallCheck/Property.hs:187:10-52
Possible fix:
add (Monad n) to the context of the instance declaration
In the instance declaration for ‘Testable n (Property m)’
```
The code is here: https://github.com/feuerbach/smallcheck/blob/v1.1.1/Test/SmallCheck/Property.hs\#L187-L188
Originally reported here: https://github.com/feuerbach/smallcheck/issues/28
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| 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 infer Monad n from (Monad m, m ~ n)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This looks like a regression in GHC HEAD.\r\n\r\n{{{\r\nTest/SmallCheck/Property.hs:187:10:\r\n Could not deduce (Monad n)\r\n arising from the superclasses of an instance declaration\r\n from the context: (Monad m, m ~ n)\r\n bound by the instance declaration\r\n at Test/SmallCheck/Property.hs:187:10-52\r\n Possible fix:\r\n add (Monad n) to the context of the instance declaration\r\n In the instance declaration for ‘Testable n (Property m)’\r\n}}}\r\n\r\nThe code is here: https://github.com/feuerbach/smallcheck/blob/v1.1.1/Test/SmallCheck/Property.hs#L187-L188\r\n\r\nOriginally reported here: https://github.com/feuerbach/smallcheck/issues/28","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1