Skip to content

Error message: "accepting non-standard pattern guards" when there are no actual patterns

This code:

{-# LANGUAGE NoPatternGuards #-}

main :: IO ()
main = print (foo 5)

foo :: Int -> Int
foo x | x < 5, x > 1 = x
      | otherwise    = -1

Produces this message:

test.hs:7:7: warning:
    accepting non-standard pattern guards (use PatternGuards to suppress this message)
        x < 5, x > 1

This is not really a "pattern guard". It's just a guard with multiple clauses, which is a syntax extension that's enabled by -XPatternGuards, but there are no patterns.

(Incidentally, I wish I could disable pattern guards to avoid the f x |x<-4 problem where a student tries to compare to negative 4 and gets an accidental pattern guard, yet still keep the multiple-clause syntax; but that's a whole different can of worms.)

Trac metadata
Trac field Value
Version 8.6.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information