[GHC] #10997: Pattern synonym causes Iface error.

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- From the mailing list.. Hello, We have a pattern synonym as follows type family Showable (a :: k) :: Constraint where Showable (a :: *) = (Show a) Showable a = () pattern Just' :: () => (Showable a) => a -> (Maybe a) pattern Just' a <- (extractJust -> (True, a)) where Just' a = Just a When we try to use the pattern in a different package, the error was [1 of 1] Compiling Bar ( Bar.hs, .stack- work/dist/x86_64-linux/Cabal-1.22.4.0/build/Bar.o ) /tmp/test/p2/.stack- work/install/x86_64-linux/lts-3.5/7.10.2/lib/x86_64-linux- ghc-7.10.2/p1-0.1.0.0-I5t4il6dN7vIqsT1XgYsM3/Foo.hi Declaration for Just' Pattern synonym Just': Iface type variable out of scope: k Cannot continue after interface file error The error only occurred when Showable was polykinded and we used synonym in a different package . Using the synonym in the same package works fine. This problem did not happen with the following definition of (non polykinded ) Showable type family Showable a :: Constraint where Showable a = (Show a) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by mpickering: Old description:
From the mailing list..
Hello,
We have a pattern synonym as follows
type family Showable (a :: k) :: Constraint where Showable (a :: *) = (Show a) Showable a = ()
pattern Just' :: () => (Showable a) => a -> (Maybe a) pattern Just' a <- (extractJust -> (True, a)) where Just' a = Just a
When we try to use the pattern in a different package, the error was
[1 of 1] Compiling Bar ( Bar.hs, .stack- work/dist/x86_64-linux/Cabal-1.22.4.0/build/Bar.o ) /tmp/test/p2/.stack- work/install/x86_64-linux/lts-3.5/7.10.2/lib/x86_64-linux- ghc-7.10.2/p1-0.1.0.0-I5t4il6dN7vIqsT1XgYsM3/Foo.hi Declaration for Just' Pattern synonym Just': Iface type variable out of scope: k Cannot continue after interface file error
The error only occurred when Showable was polykinded and we used synonym in a different package . Using the synonym in the same package works fine.
This problem did not happen with the following definition of (non polykinded ) Showable
type family Showable a :: Constraint where Showable a = (Show a)
New description: From the mailing list.. Hello, We have a pattern synonym as follows {{{ type family Showable (a :: k) :: Constraint where Showable (a :: *) = (Show a) Showable a = () pattern Just' :: () => (Showable a) => a -> (Maybe a) pattern Just' a <- (extractJust -> (True, a)) where Just' a = Just a }}} When we try to use the pattern in a different package, the error was {{{ [1 of 1] Compiling Bar ( Bar.hs, .stack- work/dist/x86_64-linux/Cabal-1.22.4.0/build/Bar.o ) /tmp/test/p2/.stack- work/install/x86_64-linux/lts-3.5/7.10.2/lib/x86_64-linux- ghc-7.10.2/p1-0.1.0.0-I5t4il6dN7vIqsT1XgYsM3/Foo.hi Declaration for Just' Pattern synonym Just': Iface type variable out of scope: k Cannot continue after interface file error }}} The error only occurred when Showable was polykinded and we used synonym in a different package . Using the synonym in the same package works fine. This problem did not happen with the following definition of (non polykinded ) Showable {{{ type family Showable a :: Constraint where Showable a = (Show a) }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Does this amount to a reproducible test case? What is `Bar.hs`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * Attachment "bug.tar.gz" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): Yes, see the attached file and run "stack build" in p2/ is one way. Another way to trigger it is to have, two files `Foo.hs` and `Bar.hs` as follows. Then run the following commands.. {{{ ghc Bar.hs vim Bar.hs .... make a simple change... ghc Bar.hs }}} {{{ [2 of 2] Compiling Bar ( Bar.hs, Bar.o ) The interface for ‘Foo’ Declaration for Just' Pattern synonym Just': Iface type variable out of scope: k Cannot continue after interface file error }}} {{{ {-# LANGUAGE PatternSynonyms, ViewPatterns, ConstraintKinds, TypeFamilies, PolyKinds, KindSignatures #-} module Foo where import GHC.Exts type family Showable (a :: k) :: Constraint where Showable (a :: *) = (Show a) Showable a = () extractJust :: Maybe a -> (Bool, a) extractJust (Just a) = (True, a) extractJust _ = (False, undefined) pattern Just' :: () => (Showable a) => a -> (Maybe a) pattern Just' a <- (extractJust -> (True, a)) where Just' a = Just a }}} {{{ module Bar where import Foo bar :: (Showable a) => Maybe a -> Maybe a bar (Just' a) = Just' a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error.
-------------------------------------+-------------------------------------
Reporter: mpickering | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T10997 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => PatternSynonyms * testcase: => typecheck/should_compile/T10997 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T10997 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): I am also affected by this bug when using `-fobject-code`. Given {{{ #!haskell {-# LANGUAGE GADTs, PatternSynonyms #-} module Foo where data Exp ty where LitB :: Bool -> Exp Bool pattern Tru :: b ~ Bool => Exp b pattern Tru = LitB True }}} and {{{ #!haskell module Bar where import Foo foo :: Exp a -> String foo Tru = "True" }}} results in the following session: {{{ % ghci -ignore-dot-ghci GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help Prelude> :load Bar [1 of 2] Compiling Foo ( Foo.hs, interpreted ) [2 of 2] Compiling Bar ( Bar.hs, interpreted ) Ok, modules loaded: Bar, Foo. *Bar> :set -fobject-code *Bar> :load Foo [1 of 1] Compiling Foo ( Foo.hs, Foo.o ) Ok, modules loaded: Foo. Prelude Foo> :load Bar [2 of 2] Compiling Bar ( Bar.hs, Bar.o ) The interface for ‘Foo’ Declaration for Tru Pattern synonym Tru: Iface type variable out of scope: k Cannot continue after interface file error
}}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T10997 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Also triggered by: {{{ % ghc Foo [1 of 1] Compiling Foo ( Foo.hs, Foo.o ) % ghc Bar [2 of 2] Compiling Bar ( Bar.hs, Bar.o ) The interface for ‘Foo’ Declaration for Tru Pattern synonym Tru: Iface type variable out of scope: k Cannot continue after interface file error }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T10997 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * priority: normal => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error.
-------------------------------------+-------------------------------------
Reporter: mpickering | Owner:
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| typecheck/should_compile/T10997
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: merge Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T10997, | T10997_1 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: typecheck/should_compile/T10997 => patsyn/should_compile/T10997, T10997_1 * status: new => merge Comment: Thanks for reporting this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: merge Priority: high | Milestone: 7.10.3 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T10997, | T10997_1 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * milestone: => 7.10.3 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10997: Pattern synonym causes Iface error. -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: closed Priority: high | Milestone: 7.10.3 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T10997, | T10997_1 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10997#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC