diff options
author | Ian Lynagh <igloo@earth.li> | 2010-08-08 15:57:32 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-08-08 15:57:32 +0000 |
commit | 4186a2d5ae04d985fe141a8701fd75d05760f7f7 (patch) | |
tree | 3d76a8fe356e54921e33571b50d99df08c3bb4d3 | |
parent | 10c4d1944f27aa7dc939ccb7e17e780602bdc47d (diff) | |
download | haskell-4186a2d5ae04d985fe141a8701fd75d05760f7f7.tar.gz |
Make a parse error say what it is failing to parse; part of #3811
-rw-r--r-- | compiler/parser/RdrHsSyn.lhs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs index ac1a02826d..4c1da58d8f 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 <variable> :: <type>" +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 <variable> :: <type>" -- 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 |