Opened 13 years ago

Closed 10 years ago

Last modified 6 years ago

#851 closed bug (wontfix)

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 Test Case: ds061
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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 (7)

comment:1 Changed 13 years ago by simonpj

Milestone: _|_
Priority: normallow

See Task #595

comment:2 Changed 13 years ago by igloo

Keywords: warnings added
Test Case: ds061

comment:3 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:5 Changed 10 years ago by igloo

Resolution: wontfix
Status: newclosed
Type of failure: None/Unknown

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

comment:6 Changed 6 years ago by Ian Lynagh <igloo@…>

In 58352225f6808b918f7f41ac8596712e68fcf23a/ghc:

Add test ds061 for trac #851 (incomplete pattern warnings wrong with n+k pats)

comment:7 Changed 6 years ago by Ian Lynagh <igloo@…>

In fef7a82c6897afb5196ca91a097c5d6b2462d4b7/ghc:

ds060 and ds061 are broken: trac #322, #851
Note: See TracTickets for help on using tickets.