@@ -1575,9 +1575,9 @@ addImpl' :: Bool -> [Name] -> IState -> PTerm -> PTerm
15751575addImpl' inpat env ist ptm = ai env ptm
15761576 where
15771577 ai env (PRef fc f)
1578− | not (f `elem` env) = handleErr $ aiFn inpat ist fc f []
1578+ | not (f `elem` env) = handleErr $ aiFn inpat inpat ist fc f []
15791579 ai env (PHidden (PRef fc f))
1580− | not (f `elem` env) = handleErr $ aiFn False ist fc f []
1580+ | not (f `elem` env) = handleErr $ aiFn inpat False ist fc f []
15811581 ai env (PEq fc l r) = let l' = ai env l
15821582 r' = ai env r in
15831583 PEq fc l' r'
@@ -1596,7 +1596,7 @@ addImpl' inpat env ist ptm = ai env ptm
15961596 ai env (PApp fc (PRef _ f) as)
15971597 | not (f `elem` env)
15981598 = let as' = map (fmap (ai env)) as in
1599− handleErr $ aiFn False ist fc f as'
1599+ handleErr $ aiFn inpat False ist fc f as'
16001600 ai env (PApp fc f as) = let f' = ai env f
16011601 as' = map (fmap (ai env)) as in
16021602 mkPApp fc 1 f' as'
@@ -1625,18 +1625,18 @@ addImpl' inpat env ist ptm = ai env ptm
16251625-- if in a pattern, and there are no arguments, and there's no possible
16261626-- names with zero explicit arguments, don't add implicits.
16271627
1628−aiFn :: Bool -> IState -> FC -> Name -> [PArg] -> Either Err PTerm
1629−aiFn True ist fc f []
1628+aiFn :: Bool -> Bool -> IState -> FC -> Name -> [PArg] -> Either Err PTerm
1629+aiFn inpat True ist fc f []
16301630 = case lookupCtxt Nothing f (idris_implicits ist) of
16311631 [] -> Right $ PRef fc f
16321632 alts -> if (any (all imp) alts)
1633− then aiFn False ist fc f [] -- use it as a constructor
1633+ then aiFn inpat False ist fc f [] -- use it as a constructor
16341634 else Right $ PRef fc f
16351635 where imp (PExp _ _ _) = False
16361636 imp _ = True
1637−aiFn inpat ist fc f as
1637+aiFn inpat expat ist fc f as
16381638 | f `elem` primNames = Right $ PApp fc (PRef fc f) as
1639−aiFn inpat ist fc f as
1639+aiFn inpat expat ist fc f as
16401640 -- This is where namespaces get resolved by adding PAlternative
16411641 = case lookupCtxtName Nothing f (idris_implicits ist) of
16421642 [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef fc f') (insertImpl ns as)