@@ -1622,7 +1622,13 @@ addImpl' inpat env infns imp_meths ist ptm
1622-- if in a pattern, and there are no arguments, and there's no possible
1622-- if in a pattern, and there are no arguments, and there's no possible
1623-- names with zero explicit arguments, don't add implicits.
1623-- names with zero explicit arguments, don't add implicits.
1625−aiFn :: Bool -> Bool -> Bool -> [Name] -> IState -> FC -> Name -> FC -> [[T.Text]] -> [PArg] -> Either Err PTerm
1625+aiFn :: Bool -> Bool -> Bool
1628+ -> Name -- ^ function being applied
1629+ -> FC -> [[T.Text]]
1630+ -> [PArg] -> -- ^ initial arguments
1626aiFn inpat True qq imp_meths ist fc f ffc ds []
1632aiFn inpat True qq imp_meths ist fc f ffc ds []
1627 = case lookupDef f (tt_ctxt ist) of
1633 = case lookupDef f (tt_ctxt ist) of
1628 [] -> Right $ PPatvar ffc f
1634 [] -> Right $ PPatvar ffc f
@@ -1685,8 +1691,20 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
1685 Just (n,t) -> t
1691 Just (n,t) -> t
1686 _ -> Public
1692 _ -> Public
1688− insertImpl :: [PArg] -> [PArg] -> [PArg]
1694+ insertImpl :: [PArg] -- ^ expected argument types (from idris_implicits)
1695+ -> [PArg] -- ^ given arguments
1698+ = let (as', badimpls) = partition (impIn ps) as in
1699+ map addUnknownImp badimpls ++
1689− insertImpl ps as = insImpAcc M.empty ps (filter exp as) (filter (not . exp) as)
1700+ insImpAcc M.empty ps (filter exp as') (filter (not . exp) as')
1702+ -- return True if the second argument is an implicit argument which is
1703+ -- expected in the implicits, or if it's not an implicit
1704+ impIn :: [PArg] -> PArg -> Bool
1705+ impIn ps (PExp _ _ _ _) = True
1706+ impIn ps (PConstraint _ _ _ _) = True
1707+ impIn ps arg = any (\p -> pname arg == pname p) ps
1691 exp (PExp _ _ _ _) = True
1709 exp (PExp _ _ _ _) = True
1692 exp (PConstraint _ _ _ _) = True
1710 exp (PConstraint _ _ _ _) = True
@@ -1723,12 +1741,11 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
1723 insImpAcc (M.insert n Placeholder pnas) ps given imps
1741 insImpAcc (M.insert n Placeholder pnas) ps given imps
1724 else PTacImplicit p l n sc sc :
1742 else PTacImplicit p l n sc sc :
1725 insImpAcc (M.insert n sc pnas) ps given imps
1743 insImpAcc (M.insert n sc pnas) ps given imps
1726− insImpAcc _ expected [] imps = imps -- so that unused implicits give error
1744+ insImpAcc _ expected [] imps = map addUnknownImp imps -- so that unused implicits give error
1727− -- TODO: report here, and prune alternatives
1728− -- Issue #1740 in the Issue Tracker
1729−-- https://github.com/idris-lang/Idris-dev/issues/1740
1730 insImpAcc _ _ given imps = given ++ imps
1745 insImpAcc _ _ given imps = given ++ imps
1747+ addUnknownImp arg = arg { argopts = UnknownImp : argopts arg }
1732 find n [] acc = Nothing
1749 find n [] acc = Nothing
1733 find n (PImp _ _ _ n' t : gs) acc
1750 find n (PImp _ _ _ n' t : gs) acc
1734 | n == n' = Just (t, reverse acc ++ gs)
1751 | n == n' = Just (t, reverse acc ++ gs)