Commit 6703ea08 authored by Kai-Oliver Prott's avatar Kai-Oliver Prott
Browse files

Fix issue with type checking ambiguous functions in instances

parent 1bf173b5
......@@ -496,10 +496,24 @@ checkInstanceDecl (InstanceDecl p cx qcls ty ds) = do
m <- getModuleIdent
tcEnv <- getTyConsEnv
checkMethods qcls (clsMethods m qcls tcEnv) ds
mapM_ checkAmbiguousMethod ds
InstanceDecl p cx qcls ty <$> checkTopDecls ds
checkInstanceDecl _ =
internalError "SyntaxCheck.checkInstanceDecl: no instance declaration"
checkAmbiguousMethod :: Decl a -> SCM ()
checkAmbiguousMethod (FunctionDecl _ _ f _) = do
m <- getModuleIdent
rename <- getRenameEnv
case lookupVar f rename of
rs1@(_:_:_) -> case qualLookupVar (qualifyWith m f) rename of
[] -> report $ errAmbiguousIdent rs1 (qualify f)
rs2@(_:_:_) -> report $ errAmbiguousIdent rs2 (qualify f)
_ -> return ()
_ -> return ()
checkAmbiguousMethod _ =
internalError "SyntaxCheck.checkAmbiguousMethod: no function declaration"
checkMethods :: QualIdent -> [Ident] -> [Decl a] -> SCM ()
checkMethods qcls ms ds =
mapM_ (report . errUndefinedMethod qcls) $ filter (`notElem` ms) fs
......
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