[project @ 2006-01-18 12:16:06 by simonpj]
authorsimonpj <unknown>
Wed, 18 Jan 2006 12:16:06 +0000 (12:16 +0000)
committersimonpj <unknown>
Wed, 18 Jan 2006 12:16:06 +0000 (12:16 +0000)
Check for constructors in type signatures

ghc/compiler/basicTypes/OccName.lhs
ghc/compiler/parser/RdrHsSyn.lhs

index bd6d3f7..e553cc5 100644 (file)
@@ -346,11 +346,15 @@ isValOcc other                  = False
 -- Data constructor operator (starts with ':', or '[]')
 -- Pretty inefficient!
 isDataSymOcc (OccName DataName s) = isLexConSym s
 -- Data constructor operator (starts with ':', or '[]')
 -- Pretty inefficient!
 isDataSymOcc (OccName DataName s) = isLexConSym s
-isDataSymOcc (OccName VarName s)  = isLexConSym s
+isDataSymOcc (OccName VarName s)  
+  | isLexConSym s = pprPanic "isDataSymOcc: check me" (ppr s)
+               -- Jan06: I don't think this should happen
 isDataSymOcc other               = False
 
 isDataOcc (OccName DataName _) = True
 isDataSymOcc other               = False
 
 isDataOcc (OccName DataName _) = True
-isDataOcc (OccName VarName s)  = isLexCon s
+isDataOcc (OccName VarName s)  
+  | isLexCon s = pprPanic "isDataOcc: check me" (ppr s)
+               -- Jan06: I don't think this should happen
 isDataOcc other                       = False
 
 -- Any operator (data constructor or variable)
 isDataOcc other                       = False
 
 -- Any operator (data constructor or variable)
index 6ff15e7..a955791 100644 (file)
@@ -601,9 +601,11 @@ checkValSig
        :: LHsExpr RdrName
        -> LHsType RdrName
        -> P (Sig RdrName)
        :: LHsExpr RdrName
        -> LHsType RdrName
        -> P (Sig RdrName)
-checkValSig (L l (HsVar v)) ty | isUnqual v = return (TypeSig (L l v) ty)
+checkValSig (L l (HsVar v)) ty 
+  | isUnqual v && not (isDataOcc (rdrNameOcc v))
+  = return (TypeSig (L l v) ty)
 checkValSig (L l other)     ty
 checkValSig (L l other)     ty
-  = parseError l "Type signature given for an expression"
+  = parseError l "Invalid type signature"
 
 mkGadtDecl
         :: Located RdrName
 
 mkGadtDecl
         :: Located RdrName