diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-10-15 11:11:20 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-10-15 11:11:21 -0400 |
commit | b501709ed79ba03e72518ef9dd101ce2d03db2de (patch) | |
tree | 0b3c3cfa724c39fdcaaf3426f6cc4044d4f1b7f6 /docs | |
parent | e39589e2e4f788565c4a7f02cb85802214a95757 (diff) | |
download | haskell-b501709ed79ba03e72518ef9dd101ce2d03db2de.tar.gz |
Fix Show derivation in the presence of RebindableSyntax/OverloadedStrings
Summary:
To fix this issue, we simply disable `RebindableSyntax` whenever we rename
the code generated from a deriving clause.
Fixes #12688.
Test Plan: make test TEST=T12688
Reviewers: simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2591
GHC Trac Issues: #12688
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/8.0.2-notes.rst | 4 | ||||
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 27 |
2 files changed, 31 insertions, 0 deletions
diff --git a/docs/users_guide/8.0.2-notes.rst b/docs/users_guide/8.0.2-notes.rst index 82c214e534..c8e76ed456 100644 --- a/docs/users_guide/8.0.2-notes.rst +++ b/docs/users_guide/8.0.2-notes.rst @@ -25,6 +25,10 @@ Language - A bug has been fixed that caused standalone derived ``Ix`` instances to fail for GADTs with exactly one constructor (:ghc-ticket:`12583`). +- A bug has been fixed that caused derived ``Show`` instances to fail in the + presence of :ghc-flag:`-XRebindableSyntax` and + :ghc-flag:`-XOverloadedStrings` (:ghc-ticket:`12688`). + Compiler ~~~~~~~~ diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index e76465af6d..9f0a75502c 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1460,6 +1460,33 @@ Be warned: this is an experimental facility, with fewer checks than usual. Use ``-dcore-lint`` to typecheck the desugared program. If Core Lint is happy you should be all right. +Things unaffected by :ghc-flag:`-XRebindableSyntax` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:ghc-flag:`-XRebindableSyntax` does not apply to any code generated from a +``deriving`` clause or declaration. To see why, consider the following code: :: + + {-# LANGUAGE RebindableSyntax, OverloadedStrings #-} + newtype Text = Text String + + fromString :: String -> Text + fromString = Text + + data Foo = Foo deriving Show + +This will generate code to the effect of: :: + + instance Show Foo where + showsPrec _ Foo = showString "Foo" + +But because :ghc-flag:`-XRebindableSyntax` and :ghc-flag:`-XOverloadedStrings` +are enabled, the ``"Foo"`` string literal would now be of type ``Text``, not +``String``, which ``showString`` doesn't accept! This causes the generated +``Show`` instance to fail to typecheck. It's hard to imagine any scenario where +it would be desirable have :ghc-flag:`-XRebindableSyntax` behavior within +derived code, so GHC simply ignores :ghc-flag:`-XRebindableSyntax` entirely +when checking derived code. + .. _postfix-operators: Postfix operators |