[GHC] #16411: Inconsistent -Wpartial-fields warnings with (~) vs. (~~)
#16411: Inconsistent -Wpartial-fields warnings with (~) vs. (~~) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.4 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In this program: {{{#!hs {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wpartial-fields #-} module Bug where import Data.Type.Equality data T1 z where MkT1a :: { rec1 :: () } -> T1 Int MkT1b :: (z ~ Bool) => T1 z data T2 z where MkT2a :: { rec2 :: () } -> T2 Int MkT2b :: (z ~~ Bool) => T2 z }}} I get no `-Wpartial-fields`–related warnings for `rec1`, but I do for `rec2`: {{{ GHCi, version 8.6.4: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:13:14: warning: [-Wpartial-fields] Use of partial record field selector: ‘rec2’ | 13 | MkT2a :: { rec2 :: () } -> T2 Int | ^^^^ }}} This feels strangely inconsistent, since if GHC doesn't warn for `rec1`, which uses `(~)`, then I feel like it shouldn't warn for `rec2` either, as the only difference is that the surrounding constructor uses a slightly different equality constraint `(~~)`. The reason this happens is because the `dataConCannotMatch` function has special reasoning for `(~)`, but not `(~~)`. Patch incoming. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16411> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#16411: Inconsistent -Wpartial-fields warnings with (~) vs. (~~) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/520 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => https://gitlab.haskell.org/ghc/ghc/merge_requests/520 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16411#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#16411: Inconsistent -Wpartial-fields warnings with (~) vs. (~~) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/520 -------------------------------------+------------------------------------- Comment (by Marge Bot <ben+marge-bot@…>): In [changeset:"36546a43e490ea6f989e6cad369d1a251c94a42b/ghc" 36546a4/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="36546a43e490ea6f989e6cad369d1a251c94a42b" Fix #16411 by making dataConCannotMatch aware of (~~) The `dataConCannotMatch` function (which powers the `-Wpartial-fields` warning, among other things) had special reasoning for explicit equality constraints of the form `a ~ b`, but it did not extend that reasoning to `a ~~ b` constraints, leading to #16411. Easily fixed. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16411#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC