[GHC] #15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Keywords: GHCProposal | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The [https://github.com/ghc-proposals/ghc-proposals/pull/71 proposal] has been accepted, and could be implemented. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * type: feature request => task -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: RolandSenn Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: (none) => RolandSenn -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: RolandSenn Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): FYI: ckoparkar is also working on this in Phab:D5415. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: RolandSenn Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * Attachment "incomplete-record-updates.log" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: RolandSenn Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * Attachment "incomplete-uni-patterns.log" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: RolandSenn Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ckoparkar): RolandSenn, feel free to commandeer that patch. Adding the flags to {{{-Wall}}} was the easy part, and that's done. However, we still need to do something about the code in GHC which is unsafe per these two flags. (Attached the build/error log). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: RolandSenn => (none) Comment: @ckoparkar, @RyanGlScott: Ops, this ticket contains more fun than I expected! Most of these ''incomplete patterns'' are already a very long time in the GHC and libraray code, so we can assume, they are nearly never a problem. The new warnings do not make the code safer or more unsafe. GHC now just reminds us, that there is unsafe code. To fix, we have 3 possibilities: 1. Add a pragma to skip the warning to every affected module. This has the advantage, that we don't change the semantics of any GHC or library module. 2. Add the missing patterns, and call panic! This has the advantage, that if we really ever hit such a case, the user gets a nicer error message, and is invited to report the problem. 3. Add the missing patterns and add (maybe) intelligent code to the RHS of the pattern. This has the **disadvantage**, that we add a lot of code. Unfortunately will be unable to test this new code. This is very bad! I think, we should concentrate on option 1 or 2. The difference in the amount of work is marginal, however, I don't really know, which one is ''the GHC way'' to solve this issue. Ryan (and others!) please advice! Both solutions (1 and 2) are not difficult but a fair amount of work. We should only do it, if we know, that the solution will be accepted by code review. In addition we have to decide, who does the work: I don't mind to do everything, or just a part (libraries or GHC) or nothing. **The decisions are up to you! ** PS: Till now I never did something in the libraries, so I'll probably need some guidance, eg how and where to specify the bumped version numbers of the modified libraries. PSS: Thanks to ckoparkar for the two attachments. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Option (2) seems like the obvious choice (at first) -- but then we realize that doing it means that we have to really change a lot of syntax! In particular, incomplete record updates cannot be cleanly refactored. We also have another option: 4. Refine GHC's types so that these warnings go away. For example, if we have {{{#!hs data T = MkT1 { foo :: Int } | MkT2 { bar :: Bool } }}} and have `t { foo = 5 }` somewhere, we'll get an error. But perhaps there is enough logic to suggest that `t` will always be a `MkT1`. We could refactor to {{{#!hs data T = MkT1 T1 | MkT2 T2 data T1 = Mk1 { foo :: Int } data T2 = Mk2 { bar :: Bool } }}} and then our variable `t` would have type `T1` instead of `T` and all would be well. Of course, this refactoring introduces new memory allocations at runtime, and it may be hard to make all the types work out. It's thus impractical. However, it suggests a way forward here: Do (1), but make (4) the end goal. That is, just squash the warnings for now, but have it be an explicit goal (with a ticket to track the goal) to remove the squashings. This would mean, e.g., that we would need a way for the refactoring above ''not'' to take extra allocations at runtime. (This would be a huge improvement for Haskell overall!) And we'd likely need dependent types :). But all this would be very nice concrete fodder for why such improvements are called for. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * cc: RolandSenn (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RolandSenn): @ckoparkar: Just go ahead! Grab the ticket and do the changes outlined by goldfire in [https://ghc.haskell.org/trac/ghc/ticket/15656#comment:6 comment:6]. It's not so much work, as you only have to add one line to every module (not line!) listed in your attachments. The really difficult work will be postponed to the new ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: ckoparkar Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * owner: (none) => ckoparkar Comment: Thanks RolandSenn. Updating that patch now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: ckoparkar Type: task | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16041 | Differential Rev(s): Phab:D5415 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * differential: => Phab:D5415 * related: => #16041 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15656: Extend -Wall with incomplete-uni-patterns and incomplete-record-updates -------------------------------------+------------------------------------- Reporter: ckoparkar | Owner: ckoparkar Type: task | Status: patch Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: GHCProposal Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16041 | Differential Rev(s): Phab:D5415 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15656#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC