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 (cherry picked from commit 575c009d)
Showing
- compiler/hsSyn/Convert.hs 14 additions, 3 deletionscompiler/hsSyn/Convert.hs
- compiler/hsSyn/HsLit.hs 26 additions, 0 deletionscompiler/hsSyn/HsLit.hs
- compiler/hsSyn/HsPat.hs 55 additions, 0 deletionscompiler/hsSyn/HsPat.hs
- compiler/hsSyn/HsTypes.hs 3 additions, 2 deletionscompiler/hsSyn/HsTypes.hs
- compiler/hsSyn/HsUtils.hs 6 additions, 3 deletionscompiler/hsSyn/HsUtils.hs
- compiler/typecheck/TcGenDeriv.hs 4 additions, 2 deletionscompiler/typecheck/TcGenDeriv.hs
- testsuite/tests/deriving/should_compile/T14682.hs 10 additions, 0 deletionstestsuite/tests/deriving/should_compile/T14682.hs
- testsuite/tests/deriving/should_compile/T14682.stderr 194 additions, 0 deletionstestsuite/tests/deriving/should_compile/T14682.stderr
- testsuite/tests/deriving/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/deriving/should_compile/all.T
- testsuite/tests/th/T14681.hs 9 additions, 0 deletionstestsuite/tests/th/T14681.hs
- testsuite/tests/th/T14681.stderr 11 additions, 0 deletionstestsuite/tests/th/T14681.stderr
- testsuite/tests/th/all.T 1 addition, 0 deletionstestsuite/tests/th/all.T
Loading
Please register or sign in to comment