[GHC] #12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple rebindablesyntax | overloadedstrings deriving show | string | Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When using both `RebindableSyntax` and `OverloadedStrings`, `deriving (Show)` no longer works. Example program: {{{#!hs {-# LANGUAGE RebindableSyntax, OverloadedStrings #-} module Bug where import Prelude (String,Show(..)) newtype Text = Text String fromString :: String -> Text fromString = Text x :: Text x = "x" newtype Foo = Foo () deriving (Show) }}} In this example, `fromString` is redefined to return a type different from `[Char]`. The example `x` typechecks due to to the `RebindableSyntax` and `OverloadedStrings` extensions. However, the generated code for the `deriving (Show)` instance for Foo does not typecheck, and ghc gives a code generation error: {{{#!hs error: • Couldn't match type ‘Text’ with ‘[GHC.Types.Char]’ Expected type: String Actual type: Text • In the first argument of ‘GHC.Show.showString’, namely ‘"Foo "’ In the first argument of ‘(GHC.Base..)’, namely ‘(GHC.Show.showString "Foo ")’ In the second argument of ‘GHC.Show.showParen’, namely ‘((GHC.Base..) (GHC.Show.showString "Foo ") (showsPrec 11 b1))’ When typechecking the code for ‘showsPrec’ in a derived instance for ‘Show Foo’: To see the code I am typechecking, use -ddump-deriv }}} A solution would be to protect the code generated by `deriving (Show)` from `OverloadedStrings` and `RebindableSyntax` extensions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | rebindablesyntax overloadedstrings | deriving show string 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 simonpj): * cc: RyanGlScott (added) * owner: => RyanGlScott Comment:
A solution would be to protect the code generated by deriving (Show) from OverloadedStrings and RebindableSyntax extensions.
Yes, I think that's probably the right solution. Ryan, do you agree? Might you do it? I think it's a matter of fiddling with `ib_extensions`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | rebindablesyntax overloadedstrings | deriving show string 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: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Well, we've certainly changed the way deriving works in the past to accommodate the presence of `RebindableSyntax` (see #11396 and #12080 for examples). But those were quite small, non-invasive changes. On the other hand, derived `Show` instances make heavy use of string literals, so I don't think changing the derived `Show` methods is really an option here. Simon, are you suggesting just disabling `RebindableSyntax` entirely for derived code? I'd be fine with that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | rebindablesyntax overloadedstrings | deriving show string 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: | -------------------------------------+------------------------------------- Comment (by simonpj):
Simon, are you suggesting just disabling RebindableSyntax entirely for derived code? I'd be fine with that.
Yes, exactly Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | rebindablesyntax overloadedstrings | deriving show string 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:D2591 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D2591 * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from
RebindableSyntax+OverloadedStrings
-------------------------------------+-------------------------------------
Reporter: daviddarais | Owner: RyanGlScott
Type: bug | Status: patch
Priority: normal | Milestone: 8.0.2
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
| rebindablesyntax overloadedstrings
| deriving show string
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:D2591
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | rebindablesyntax overloadedstrings | deriving show string Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | deriving/should_compile/T12688 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2591 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => deriving/should_compile/T12688 * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12688: derived Show instances aren't protected from RebindableSyntax+OverloadedStrings -------------------------------------+------------------------------------- Reporter: daviddarais | Owner: RyanGlScott Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: | rebindablesyntax overloadedstrings | deriving show string Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | deriving/should_compile/T12688 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2591 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as d7a1f682af766e6c1529932b24bada9053d5c4da. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12688#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC