[project @ 2002-04-22 13:08:34 by simonmar]
authorsimonmar <unknown>
Mon, 22 Apr 2002 13:08:34 +0000 (13:08 +0000)
committersimonmar <unknown>
Mon, 22 Apr 2002 13:08:34 +0000 (13:08 +0000)
Throw out OpApp patterns where the operator is not a constructor here,
rather than later in the typechecker(!).

ghc/compiler/parser/ParseUtil.lhs

index 9b8b6c9..6314914 100644 (file)
@@ -49,7 +49,7 @@ import SrcLoc
 import RdrHsSyn
 import RdrName
 import PrelNames       ( unitTyCon_RDR )
-import OccName         ( dataName, varName, tcClsName,
+import OccName         ( dataName, varName, tcClsName, isDataOcc,
                          occNameSpace, setOccNameSpace, occNameUserString )
 import CStrings                ( CLabelString )
 import FastString      ( nullFastString )
@@ -212,7 +212,8 @@ checkPat e [] = case e of
        OpApp l op fix r   -> checkPat l [] `thenP` \l ->
                              checkPat r [] `thenP` \r ->
                              case op of
-                                HsVar c -> returnP (ConOpPatIn l c fix r)
+                                HsVar c | isDataOcc (rdrNameOcc c)
+                                       -> returnP (ConOpPatIn l c fix r)
                                 _ -> patFail
 
        HsPar e            -> checkPat e [] `thenP` (returnP . ParPatIn)