[commit: ghc] master: Fix #14681 and #14682 with precision-aimed parentheses (575c009)

git at git.haskell.org git at git.haskell.org
Thu Jan 18 18:03:06 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/575c009d9e4b25384ef984c09b2c54f909693e93/ghc

>---------------------------------------------------------------

commit 575c009d9e4b25384ef984c09b2c54f909693e93
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Thu Jan 18 11:06:42 2018 -0500

    Fix #14681 and #14682 with precision-aimed parentheses
    
    It turns out that `Convert` was recklessly leaving off
    parentheses in two places:
    
    * Negative numeric literals
    * Patterns in lambda position
    
    This patch fixes it by adding three new functions, `isCompoundHsLit`,
    `isCompoundHsOverLit`, and `isCompoundPat`, and using them in the
    right places in `Convert`. While I was in town, I also sprinkled
    `isCompoundPat` among some `Pat`-constructing functions in `HsUtils`
    to help avoid the likelihood of this problem happening in other
    places. One of these places is in `TcGenDeriv`, and sprinkling
    `isCompountPat` there fixes #14682
    
    Test Plan: make test TEST="T14681 T14682"
    
    Reviewers: alanz, goldfire, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #14681, #14682
    
    Differential Revision: https://phabricator.haskell.org/D4323


>---------------------------------------------------------------

575c009d9e4b25384ef984c09b2c54f909693e93
 compiler/hsSyn/Convert.hs                          |  17 +-
 compiler/hsSyn/HsLit.hs                            |  26 +++
 compiler/hsSyn/HsPat.hs                            |  55 ++++++
 compiler/hsSyn/HsTypes.hs                          |   5 +-
 compiler/hsSyn/HsUtils.hs                          |   9 +-
 compiler/typecheck/TcGenDeriv.hs                   |   6 +-
 testsuite/tests/deriving/should_compile/T14682.hs  |  10 ++
 .../tests/deriving/should_compile/T14682.stderr    | 194 +++++++++++++++++++++
 testsuite/tests/deriving/should_compile/all.T      |   1 +
 testsuite/tests/th/T14681.hs                       |   9 +
 testsuite/tests/th/T14681.stderr                   |  11 ++
 testsuite/tests/th/all.T                           |   1 +
 12 files changed, 334 insertions(+), 10 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 575c009d9e4b25384ef984c09b2c54f909693e93


More information about the ghc-commits mailing list