Opened 8 months ago

Last modified 7 months ago

#16128 new feature request

Pattern match checker should shortcut on simple cases

Reported by: gbaz Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.3
Keywords: PatternMatchWarnings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I'm autogenerating with TH some code that does a giant string pattern match on up to 60 cases. This match clause includes a default case, but nonetheless I get a warning:

Pattern match checker exceeded (2000000) iterations in a case alternative. (Use -fmax-pmcheck-iterations=n to set the maximun number of iterations to n)

Note that in my case all the strings share a great deal in their common prefixes, which probably doesn't help matters.

It seems to me that in a case like this, GHC should be able to just check that there are no duplicate strings (i.e. no overlaps) and that there is a default case (i.e. no incompleteness) rather than running the full checker algo.

I'm not quite sure if there's a good way to generalize such a proposed shortcut so it is not too much of a special case, but likely something could be done?

Change History (3)

comment:1 Changed 8 months ago by RyanGlScott

Keywords: PatternMatchWarnings added

comment:2 Changed 8 months ago by simonpj

It seems to me that in a case like this, GHC should be able to just check that there are no duplicate strings

I agree that such a simple use-case should not make the pattern match checker have a heart attack.

The pattern-match checker badly needs someone to love it. It's basically in quite good shape, with a published paper to explain how it works. But it suffers from having no active maintainer -- except the ever-energetic Ryan S, who has many other things on his radar.

Who would like to do this? Many people would thank you! See PatternMatchCheck for a list of open tickets.

comment:3 Changed 7 months ago by Marge Bot <ben+marge-bot@…>

In d97f0db/ghc:

Fix test for T16180 on Darwin (fix #16128)
Note: See TracTickets for help on using tickets.