[GHC] #13677: Incorrect parenthesization of type in error message
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Poor/confusing Unknown/Multiple | error message Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If you compile this program: {{{#!hs {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE GADTs #-} import GHC.Exts (Constraint) data Dict a where Dict :: a => Dict a foo :: Dict (Int ~ Int) => Int foo = undefined }}} In GHC 8.0.1, 8.0.2, 8.2.1, or HEAD, it will give this error message: {{{ GHCi, version 8.3.20170509: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug2.hs, interpreted ) Bug2.hs:9:8: error: • Expected a constraint, but ‘Dict Int ~ Int’ has kind ‘*’ • In the type signature: foo :: Dict (Int ~ Int) => Int | 9 | foo :: Dict (Int ~ Int) => Int | ^^^^^^^^^^^^^^^^ }}} But `Dict Int ~ Int` is not parenthesized correctly! This is a regression, as GHC 7.10.3 and earlier parenthesize it correctly: {{{ GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( Bug2.hs, interpreted ) Bug2.hs:9:8: Expected a constraint, but ‘Dict (Int ~ Int)’ has kind ‘*’ In the type signature for ‘foo’: foo :: Dict (Int ~ Int) => Int }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Commit 09b872dc61590a71c28feb37c37bf864664efaf7 (Make equality print better. (#11712)) is responsible. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3570 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"2277172ac3ea0bbeddebc9999a5d8b5f9f58afc9/ghc" 2277172a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2277172ac3ea0bbeddebc9999a5d8b5f9f58afc9" Parenthesize pretty-printed equalities when necessary Fixes #13677 by parenthesizing equalities in a sufficiently high pretty-printing context. Test Plan: make test TEST=T13677 Reviewers: goldfire, austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13677 Differential Revision: https://phabricator.haskell.org/D3570 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged with 66d5e8015bed91fd0e2091641fe855c433c24b6c. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"ad14efd539377aaf472ad69449dcaf3e679b0e51/ghc" ad14efd/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="ad14efd539377aaf472ad69449dcaf3e679b0e51" Some tidying up of type pretty-printing Triggered by the changes in #13677, I ended up doing a bit of refactoring in type pretty-printing. * We were using TyOpPrec and FunPrec rather inconsitently, so I made it consisent. * That exposed the fact that we were a bit undecided about whether to print a + b -> c + d vs (a+b) -> (c+d) and similarly a ~ [b] => blah vs (a ~ [b]) => blah I decided to make TyOpPrec and FunPrec compare equal (in BasicTypes), so (->) is treated as equal precedence with other type operators, so you get the unambiguous forms above, even though they have more parens. We could readily reverse this decision. See Note [Type operator precedence] in BasicTypes * I fixed a bug in pretty-printing of HsType where some parens were omitted by mistake. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13677: Incorrect parenthesization of type in error message -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3570 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): PS: no need to merge this... just tidying up -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13677#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC