Ticket #851 (closed bug: wontfix)

Opened 7 years ago

Last modified 4 years ago

Incomplete-pattern checking for n+k patterns is not implemented

Reported by: simonpj Owned by:
Priority: low Milestone: _|_
Component: Compiler Version: 6.4.2
Keywords: warnings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: ds061 Blocked By:
Blocking: Related Tickets:

Description

The check for incomplete patterns does not understand about n+k patterns. Here's an example:

f 0     = True
f (n+1) = False

GHC says, rather confusingly:

    Warning: Pattern match(es) are non-exhaustive
	     In the definition of `f':
		 Patterns not matched: #x with #x `notElem` [0#]

The reason is in compiler/deSugar/Check.hs which says

	-- Horrible hack.  The simplify_pat stuff converts NPlusK pats to WildPats
	-- which of course loses the info that they can fail to match.  So we 
	-- stick in a CanFail as if it were a guard.
	-- The Right Thing to do is for the whole system to treat NPlusK pats properly

See ticket:595

Change History

Changed 7 years ago by simonpj

  • priority changed from normal to low
  • milestone set to _|_

See Task #595

Changed 7 years ago by igloo

  • keywords warnings added
  • testcase set to ds061

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to wontfix

The !NoNPlusKPatterns proposal was accepted for H'2010, so I don't think it is worth spending time on this.

Note: See TracTickets for help on using tickets.