[GHC] #11633: Record field order in a bidirectional pattern synonym match is order dependent

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.3 (Type checker) | Keywords: | Operating System: Unknown/Multiple PatternSynonyms | Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider this example, {{{#!hs {-# LANGUAGE PatternSynonyms #-} module Test where data ARecord = ARecord {anInt :: Int, aString :: String} -- This works... pattern AGoodPat :: Int -> String -> ARecord pattern AGoodPat n s = ARecord {anInt=n, aString=s} -- But if we invert the order of the fields things break... pattern ABadPat :: Int -> String -> ARecord pattern ABadPat n s = ARecord {aString=s, anInt=n} }}} Despite the fact that `AGoodPat` and `ABadPat` differ only in the order of the fields in their matches, `ABadPat` fails to typecheck with, {{{ Test.hs:12:40: error: • Couldn't match type ‘[Char]’ with ‘Int’ Expected type: Int Actual type: String • In the first argument of ‘ARecord’, namely ‘s’ In the expression: ARecord s n In an equation for ‘$bABadPat’: $bABadPat n s = ARecord s n Test.hs:12:49: error: • Couldn't match type ‘Int’ with ‘[Char]’ Expected type: String Actual type: Int • In the second argument of ‘ARecord’, namely ‘n’ In the expression: ARecord s n In an equation for ‘$bABadPat’: $bABadPat n s = ARecord s n }}} This can be observed with both 7.10.3 and `master`. If one makes `ABadPat` into a one-directional pattern then the error vanishes. The fact that field order matters in the case of bi-directional record pattern synonyms seems a bit odd. If there's a good reason why this must be the case then fair enough, but we should make sure this is mentioned in the users guide and provide a more helpful error message. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: mpickering Type: bug | Status: new Priority: high | Milestone: Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * owner: => mpickering Comment: This is a bug which looks easy to fix but I wonder whether doing some restructuring would help prevent bugs like this in future. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: mpickering Type: bug | Status: patch Priority: high | Milestone: Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: new => patch * differential: => Phab:D1949 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: mpickering Type: bug | Status: merge Priority: high | Milestone: Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: mpickering Type: bug | Status: merge Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.0.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => new * owner: mpickering => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Merged to `master` in 52879d1f5d804bf1a32d11d9cefc36d7b6fea382. To `ghc-8.0` as 66029ccb2f98c2e7c1687b1eeb4e03750cbc263e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11633: Record field order in a bidirectional pattern synonym match is order dependent -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.3 checker) | Keywords: Resolution: fixed | PatternSynonyms Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1949 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11633#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC