Commit 53cbf3e7 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Improved reporting of multiple type signatures

Previously, only the existence of a duplicate signature was reported:

  ErrorMultipleSignature.curry, line 1.1:
      More than one type signature for `f'

Now, the occurrences are additionally reported:

  ErrorMultipleSignature.curry, line 1.1:
      More than one type signature for `f' at:
        ErrorMultipleSignature.curry, line 1.1
        ErrorMultipleSignature.curry, line 3.1
        ErrorMultipleSignature.curry, line 6.1
parent ebd64a18
......@@ -454,12 +454,13 @@ top-level.
> checkDecls :: (Decl -> RenameEnv -> RenameEnv) -> [Decl] -> SCM [Decl]
> checkDecls bindDecl ds = do
> let dbls@[dblVar, dblTys] = map findDouble [bvs, tys]
> let dblVar = findDouble bvs
> onJust (report . errDuplicateDefinition) dblVar
> onJust (report . errDuplicateTypeSig ) dblTys
> let missingTy = [f | ExternalDecl _ fs' <- ds, f <- fs', f `notElem` tys]
> mapM_ (report . errNoTypeSig) missingTy
> if all isNothing dbls && null missingTy
> let mulTys = findMultiples tys
> mapM_ (report . errDuplicateTypeSig) mulTys
> let missingTys = [f | ExternalDecl _ fs' <- ds, f <- fs', f `notElem` tys]
> mapM_ (report . errNoTypeSig) missingTys
> if isNothing dblVar && null mulTys && null missingTys
> then do
> modifyRenameEnv $ \env -> foldr bindDecl env (tds ++ vds)
> mapM (checkDeclRhs bvs) ds
......@@ -1021,12 +1022,15 @@ Error messages.
> errMultipleDataConstructor (i:is) = posMessage i $
> text "Multiple definitions for data constructor" <+> text (escName i)
> <+> text "at:" $+$
> nest 2 (vcat (map showPos (i:is)))
> where showPos = text . showLine . idPosition
> nest 2 (vcat (map (ppPosition . getPosition) (i:is)))
> errDuplicateTypeSig :: Ident -> Message
> errDuplicateTypeSig v = posMessage v $ hsep $ map text
> ["More than one type signature for", escName v]
> errDuplicateTypeSig :: [Ident] -> Message
> errDuplicateTypeSig [] = internalError
> "SyntaxCheck.errDuplicateTypeSig: empty list"
> errDuplicateTypeSig (v:vs) = posMessage v $
> text "More than one type signature for" <+> text (escName v)
> <+> text "at:" $+$
> nest 2 (vcat (map (ppPosition . getPosition) (v:vs)))
> errDuplicateLabel :: Ident -> Message
> errDuplicateLabel l = posMessage l $ hsep $ map text
......
f :: a -> a
f :: b -> b
f x = x
f :: c -> c
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment