[GHC] #14569: refutable let bindings produce "irrefutable pattern failed" errors
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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: -------------------------------------+------------------------------------- In ghc-8.2.2 (probably since ghc-8.0.1), strict pattern matches in let bindings produce "Irrefutable pattern failed" errors. {{{#!hs GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Prelude> :set -XBangPatterns Prelude> let ![] = [1] in 1 *** Exception: <interactive>:2:5-13: Irrefutable pattern failed for pattern [] }}} In ghc-7.10.2, normal pattern match failures were produced. {{{#!hs GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help Prelude> :set -XBangPatterns Prelude> let ![] = [1] in 1 *** Exception: <interactive>:3:5-13: Non-exhaustive patterns in pattern binding }}} To my mind, the latter error makes much more sense; the effect of the ! is to make the pattern an ordinary, refutable one. Could the old behavior be restored? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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 simonpj): I rather agree. Actually even 7.10 had this behaviour. Try {{{ main = let [x] = [] in print (x::Int) }}} and you get the runtime crash (with 7.10) {{{ run: T14569.hs:3:12-19: Irrefutable pattern failed for pattern [x] }}} The real point is: this talk of "irrefutable" patterns is confusing, especially since this one is manifestly refutable. Suggestion: uniformly replace the "Irrefutable pattern failed" message with "Non-exhaustive patterns in pattern binding". To do this * Kill off `Control.Exception.Base.irrefutPatError` * Kill off `MkCore.iRREFUT_PAT_ERROR_ID` and its `Name`, unique, etc. * Use `pAT_ERROR_ID` wherever we currently use `iRREFUT_PAT_ERROR_ID`. Ben, if everyone is happy, would you like to execute on this? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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 int-e): Replying to [comment:1 simonpj]:
I rather agree. Actually even 7.10 had this behaviour. Try {{{ main = let [x] = [] in print (x::Int) }}} and you get the runtime crash (with 7.10) {{{ run: T14569.hs:3:12-19: Irrefutable pattern failed for pattern [x] }}}
The difference here is that here the pattern is actually (implicitly) irrefutable as per the Haskell 2010 language report. However,
The real point is: this talk of "irrefutable" patterns is confusing, especially since this one is manifestly refutable.
This is a good point, the nomenclature is quite confusing, not just for beginners, but for anyone who isn't intimately familiar with the section on pattern matching in the Haskell report. I wouldn't be sad to see those errors replaced by ordinary incomplete pattern match errors. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: dfeuer Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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: | -------------------------------------+------------------------------------- Changes (by dfeuer): * owner: (none) => dfeuer Comment: This sounds like something I can probably manage. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: dfeuer Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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:D4261 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch * differential: => Phab:D4261 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: dfeuer Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 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:D4261 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"492e6044577519b59f390008362de98e9517e04d/ghc" 492e604/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="492e6044577519b59f390008362de98e9517e04d" Kill off irrefutable pattern errors Distinguishing between "refutable" and "irrefutable" patterns (as described by the Haskell Report) in incomplete pattern errors was more confusing than helpful. Remove references to irrefutable patterns. Reviewers: hvr, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #14569 Differential Revision: https://phabricator.haskell.org/D4261 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14569: refutable let bindings produce "irrefutable pattern failed" errors -------------------------------------+------------------------------------- Reporter: int-e | Owner: dfeuer Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 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:D4261 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.6.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14569#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC