From: Ian Lynagh Date: Sun, 8 Aug 2010 15:57:32 +0000 (+0000) Subject: Make a parse error say what it is failing to parse; part of #3811 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=4186a2d5ae04d985fe141a8701fd75d05760f7f7 Make a parse error say what it is failing to parse; part of #3811 --- diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs index ac1a028..4c1da58 100644 --- a/compiler/parser/RdrHsSyn.lhs +++ b/compiler/parser/RdrHsSyn.lhs @@ -799,12 +799,14 @@ checkValSig checkValSig (L l (HsVar v)) ty | isUnqual v && not (isDataOcc (rdrNameOcc v)) = return (TypeSig (L l v) ty) -checkValSig lhs@(L l _) _ - | looks_like_foreign lhs - = parseError l "Invalid type signature; perhaps you meant to use -XForeignFunctionInterface?" - | otherwise - = parseError l "Invalid type signature: should be of form :: " +checkValSig lhs@(L l _) ty + = parseErrorSDoc l ((text "Invalid type signature:" <+> + ppr lhs <+> text "::" <+> ppr ty) + $$ text hint) where + hint = if looks_like_foreign lhs + then "Perhaps you meant to use -XForeignFunctionInterface?" + else "Should be of form :: " -- A common error is to forget the ForeignFunctionInterface flag -- so check for that, and suggest. cf Trac #3805 -- Sadly 'foreign import' still barfs 'parse error' because 'import' is a keyword