[GHC] #11959: Importing doubly exported pattern synonym and associated pattern synonym panics

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Keywords: | Operating System: Unknown/Multiple PatternSynonyms | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Given {{{#!hs {-# LANGUAGE PatternSynonyms, ViewPatterns #-} module Pat (Vec2(Nil,(:>)), pattern (:>)) where newtype Vec2 a = Vec2 {unvec2 :: [a]} pattern Nil :: Vec2 a pattern Nil = Vec2 [] pattern (:>) x xs <- ((\ys -> (head $ unvec2 ys,Vec2 . tail $ unvec2 ys)) -> (x,xs)) where (:>) x xs = Vec2 (x:unvec2 xs) }}} and {{{#!hs {-# LANGUAGE PatternSynonyms #-} module Main where import Pat (Vec2(..),pattern (:>)) }}} I get: {{{ $ ghci Main.hs GHCi, version 8.0.0.20160411: http://www.haskell.org/ghc/ :? for help [1 of 2] Compiling Pat ( Pat.hs, interpreted ) Pat.hs:2:29: warning: [-Wduplicate-exports] ‘:>’ is exported by ‘(:>)’ and ‘Vec2(Nil, type (:>))’ [2 of 2] Compiling Main ( Main.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160411 for x86_64-unknown-linux): filterImports/combine (:>, :>, Nothing) (:>, Vec2{Vec2, :>, Nil}, Nothing) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Now, the warning about the duplicate export is of course correct. But the panic shouldn't happen when I try to import both the associated pattern synonym and the normal pattern synonym. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms 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 bgamari): * priority: normal => high Comment: Hmm, this is problematic. For future reference, we typically call these patterns "bundled" and not "associated" as the latter would be confusing if we ever gain the ability to associate a pattern with a typeclass. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D2132, Phab:D2133 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym
panics
-------------------------------------+-------------------------------------
Reporter: darchon | Owner:
Type: bug | Status: patch
Priority: high | Milestone: 8.0.1
Component: Compiler | Version: 8.0.1-rc3
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2132,
Wiki Page: | Phab:D2133
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.1 => 8.0.2 Comment: We're going to bump this off to 8.0.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym
panics
-------------------------------------+-------------------------------------
Reporter: darchon | Owner:
Type: bug | Status: patch
Priority: high | Milestone: 8.0.2
Component: Compiler | Version: 8.0.1-rc3
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2132,
Wiki Page: | Phab:D2133
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: fixed | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: comment:5 merged in 8736625f143d55616e76ff660d476ce4a9cdb2d9. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * status: closed => new * resolution: fixed => Comment: But comment:5 doesn't actually fix this issue. Reopening. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * cc: mpickering (added) Comment: mpickering, do you suppose you could have a look at this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Comment (by bgamari): mpickering has said that he doesn't have enough time to look at this in the near future so I may try to dust off my previous fix, Phab:D2133. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Comment (by bgamari): On Phab:D2133 Simon said (paraphrasing),
Consider these two export lists a. {{{module M( Vec2( Nil, Cons ) ) where ...}}}
b. {{{module M( Vec2( Nil, Cons ), pattern Cons ) where ...}}} {{{ These should generate precisely the same .hi file, but they don't. They look like a. {{{ exports: Vec2{Cons Nil} }}} b. {{{ exports: Cons Vec2{Cons Nil} }}}
It's not entirely clear to me that this is true. Consider these two export lists, 1. {{{module M( Vec2( Nil, Cons ) ) where ...}}} 2. {{{module M( Vec2, pattern Nil, pattern Cons ) where ...}}} These two mean quite different things for the end-user when they go to import this module. Namely, they will need to use, respectively, 1. {{{import M(Vec2(Cons))}}} 2. {{{import M(Cons)}}} Note that the user cannot import the definitions from export list (1) with import list (2) and vice versa. This means that if the user gives us export list (b) from above and we map it to the same exports as produced by export list (a), we have made a non- obvious decision for the user, who now cannot use import list (2) to import `Cons` from `M`. It is possible we have even acted against `M`'s author's will, which was to allow both import lists. While we're discussing this, I'd also point out that there is a bit of inconsistency in how we treat bundled things. Consider, {{{#!hs module AModule ( ARecord(..) ) where data ARecord = ARec { hello :: Int } }}} In this case one could use either {{{#!hs import AModule (hello) -- or... import AModule (ARecord(hello)) }}} to import `hello` (although the `ARec` constructor must be imported in "bundled" style). While this makes some amount of sense (since selectors can be easily thought of as either free-floating functions or parts of data), it does make me wonder whether we should be equally liberal in the case of patterns. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Comment (by simonpj): See also #12604 which is almost certainly a dup. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Comment (by mpickering): I don't think your comment is correct Ben. You say that
Note that the user cannot import the definitions from export list (1) with import list (2) and vice versa.
But if the pattern synonym is bundled then you can import it with the `pattern` keyword just like record selectors. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Comment (by bgamari): Ahh, right; I likely omitted the `pattern` keyword in my experiment. Thanks for catching this, Matthew. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.2 => 8.0.3 Comment: Bumping off to 8.0.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.2 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.2.2 Comment: At this point this isn't really a regression. Bumping off to 8.2.2 since we have bigger issues to handle for the already-late 8.2.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11959: Importing doubly exported pattern synonym and associated pattern synonym panics -------------------------------------+------------------------------------- Reporter: darchon | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.3 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2132, Wiki Page: | Phab:D2133 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.2 => 8.2.3 Comment: Sadly this won't be fixed for 8.2.2 either. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11959#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC