Opened 3 years ago
Last modified 16 months ago
#12694 new bug
GHC HEAD no longer reports inaccessible code
Reported by: | ezyang | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Compiler (Type checker) | Version: | 8.1 |
Keywords: | PatternMatchWarnings | Cc: | goldfire |
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | None/Unknown | Test Case: | |
Blocked By: | Blocking: | ||
Related Tickets: | #12466, #11066, #13766 | Differential Rev(s): | |
Wiki Page: |
Description
Given this A.hs:
{-# LANGUAGE GADTs #-} module A where f :: Bool ~ Int => a -> b f x = x
I get:
ezyang@sabre:~$ ghc-head --version The Glorious Glasgow Haskell Compilation System, version 8.1.20161010 ezyang@sabre:~$ ghc-head --make A.hs [1 of 1] Compiling A ( A.hs, A.o ) A.hs:4:1: warning: [-Woverlapping-patterns] Pattern match is redundant In an equation for ‘f’: f x = ...
In contrast:
ezyang@sabre:~$ ghc-8.0 --make A.hs [1 of 1] Compiling A ( A.hs, A.o ) A.hs:3:6: error: • Couldn't match type ‘Bool’ with ‘Int’ Inaccessible code in the type signature for: f :: Bool ~ Int => a -> b • In the ambiguity check for ‘f’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the type signature: f :: Bool ~ Int => a -> b
Is this expected? I'd expect at least a warning!
Change History (4)
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
I would suggest putting it under a -W
option but you've mentioned it in the ticket; in any case, I doubt it will help anyone who doesn't already know what's going on. I ran into this because I was debugging something that was marked insoluble that wasn't (very confusing! At least the "warning" is printed in ddump-tc-trace
.)
comment:3 Changed 16 months ago by
Keywords: | PatternMatchWarnings added |
---|---|
Related Tickets: | → #12466, #11066, #13766 |
comment:4 Changed 16 months ago by
It seems that in GHC 8.2, this errors again:
$ /opt/ghc/8.4.3/bin/ghc Bug.hs [1 of 1] Compiling A ( Bug.hs, Bug.o ) Bug.hs:4:7: error: • Could not deduce: a ~ b from the context: Bool ~ Int bound by the type signature for: f :: forall a b. (Bool ~ Int) => a -> b at Bug.hs:3:1-25 ‘a’ is a rigid type variable bound by the type signature for: f :: forall a b. (Bool ~ Int) => a -> b at Bug.hs:3:1-25 ‘b’ is a rigid type variable bound by the type signature for: f :: forall a b. (Bool ~ Int) => a -> b at Bug.hs:3:1-25 • In the expression: x In an equation for ‘f’: f x = x • Relevant bindings include x :: a (bound at Bug.hs:4:3) f :: a -> b (bound at Bug.hs:4:1) | 4 | f x = x | ^
Perhaps this can be closed, then?
Note: See
TracTickets for help on using
tickets.
See #12466 for an extended discussion. I wish I had a better solution.
Simon