From b785be47556f5c1128e76355471fdb5de0a1ee64 Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 18 Jan 2006 12:16:06 +0000 Subject: [PATCH] [project @ 2006-01-18 12:16:06 by simonpj] Check for constructors in type signatures --- ghc/compiler/basicTypes/OccName.lhs | 8 ++++++-- ghc/compiler/parser/RdrHsSyn.lhs | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ghc/compiler/basicTypes/OccName.lhs b/ghc/compiler/basicTypes/OccName.lhs index bd6d3f7..e553cc5 100644 --- a/ghc/compiler/basicTypes/OccName.lhs +++ b/ghc/compiler/basicTypes/OccName.lhs @@ -346,11 +346,15 @@ isValOcc other = False -- 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 -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) diff --git a/ghc/compiler/parser/RdrHsSyn.lhs b/ghc/compiler/parser/RdrHsSyn.lhs index 6ff15e7..a955791 100644 --- a/ghc/compiler/parser/RdrHsSyn.lhs +++ b/ghc/compiler/parser/RdrHsSyn.lhs @@ -601,9 +601,11 @@ checkValSig :: 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 - = parseError l "Type signature given for an expression" + = parseError l "Invalid type signature" mkGadtDecl :: Located RdrName -- 1.7.10.4