[GHC] #15851: Error message: "accepting non-standard pattern guards" when there are no actual patterns

GHC ghc-devs at haskell.org
Fri Nov 2 19:55:36 UTC 2018


#15851: Error message: "accepting non-standard pattern guards" when there are no
actual patterns
-------------------------------------+-------------------------------------
           Reporter:  cdsmith        |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.6.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 This code:

 {{{#!hs
 {-# 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.)

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15851>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list