@@ -120,7 +120,7 @@ build ist info emode opts fn tm
120120 when tydecl (do mkPat
121121 update_term liftPats
122122 update_term orderPats)
123− EState is _ impls highlights <- getAux
123+ EState is _ impls highlights _ _ <- getAux
124124 tt <- get_term
125125 ctxt <- get_context
126126 let (tm, ds) = runState (collectDeferred (Just fn) (map fst is) ctxt tt) []
@@ -165,7 +165,7 @@ buildTC ist info emode opts fn ns tm
165165 -- unification
166166 when (not (null dots)) $
167167 lift (Error (CantMatch (getInferTerm tm)))
168− EState is _ impls highlights <- getAux
168+ EState is _ impls highlights _ _ <- getAux
169169 tt <- get_term
170170 ctxt <- get_context
171171 let (tm, ds) = runState (collectDeferred (Just fn) (map fst is) ctxt tt) []
@@ -412,16 +412,6 @@ elab ist info emode opts fn tm
412412 [pimp (sUN "A") Placeholder False,
413413 pimp (sUN "B") Placeholder False,
414414 pexp l, pexp r])
415−-- _ -> try' (elab' ina (Just fc) (PApp fc (PRef fc pairCon)
416−-- [pimp (sUN "A") Placeholder False,
417−-- pimp (sUN "B") Placeholder False,
418−-- pexp l, pexp r]))
419−-- (elab' ina (Just fc) (PApp fc (PRef fc upairCon)
420−-- [pimp (sUN "A") Placeholder False,
421−-- pimp (sUN "B") Placeholder False,
422−-- pexp l, pexp r]))
423−-- True
424−
425415 elab' ina _ (PDPair fc hls p l@(PRef nfc hl n) t r)
426416 = case t of
427417 Placeholder ->
@@ -589,7 +579,9 @@ elab ist info emode opts fn tm
589579 | pattern && not reflection && not (e_qq ec) && e_nomatching ec
590580 = lift $ tfail $ Msg ("Attempting concrete match on polymorphic argument: " ++ show tm)
591581 | (pattern || intransform || (bindfree && bindable n)) && not (inparamBlock n) && not (e_qq ec)
592− = do let ina = e_inarg ec
582+ = do ty <- goal
583+ testImplicitWarning fc n ty
584+ let ina = e_inarg ec
593585 guarded = e_guarded ec
594586 inty = e_intype ec
595587 ctxt <- get_context
@@ -676,6 +668,7 @@ elab ist info emode opts fn tm
676668 highlightSource nfc (AnnBoundName n False)
677669 elab' ina fc (PPi p n nfc Placeholder sc)
678670 = do attack; arg n (is_scoped p) (sMN 0 "ty")
671+ addAutoBind p n
679672 addPSname n -- okay for proof search
680673 elabE (ina { e_inarg = True, e_intype = True }) fc sc
681674 solve
@@ -687,6 +680,7 @@ elab ist info emode opts fn tm
687680 MN _ _ -> unique_hole n
688681 _ -> return n
689682 forall n' (is_scoped p) (Var tyn)
683+ addAutoBind p n'
690684 addPSname n' -- okay for proof search
691685 focus tyn
692686 let ec' = ina { e_inarg = True, e_intype = True }
@@ -1207,7 +1201,7 @@ elab ist info emode opts fn tm
12071201 -- We now have an elaborated term. Reflect it and solve the
12081202 -- original goal in the original proof state, preserving highlighting
12091203 env <- get_env
1210− EState _ _ _ hs <- getAux
1204+ EState _ _ _ hs _ _ <- getAux
12111205 loadState
12121206 updateAux (\aux -> aux { highlighting = hs })
12131207
@@ -1403,8 +1397,8 @@ elab ist info emode opts fn tm
14031397 -- case block functions that don't yet exist)
14041398 fullyElaborated :: Term -> ElabD ()
14051399 fullyElaborated (P _ n _) =
1406− do EState cases _ _ _ <- getAux
1407− case lookup n cases of
1400+ do estate <- getAux
1401+ case lookup n (case_decls estate) of
14081402 Nothing -> return ()
14091403 Just _ -> lift . tfail $ ElabScriptStaging n
14101404 fullyElaborated (Bind n b body) = fullyElaborated body >> for_ b fullyElaborated
@@ -1549,6 +1543,31 @@ elab ist info emode opts fn tm
15491543 elabArgs _ _ _ _ _ _ (((arg, hole), _) : _) _ [] =
15501544 fail $ "Can't elaborate these args: " ++ show arg ++ " " ++ show hole
15511545
1546+ addAutoBind :: Plicity -> Name -> ElabD ()
1547+ addAutoBind (Imp _ _ _ _ False) n
1548+ = updateAux (\est -> est { auto_binds = n : auto_binds est })
1549+ addAutoBind _ _ = return ()
1550+
1551+ testImplicitWarning :: FC -> Name -> Type -> ElabD ()
1552+ testImplicitWarning fc n goal
1553+ | implicitable n && emode == ETyDecl
1554+ = do env <- get_env
1555+ est <- getAux
1556+ when (n `elem` auto_binds est) $
1557+ tryUnify env (lookupTyName n (tt_ctxt ist))
1558+ | otherwise = return ()
1559+ where
1560+ tryUnify env [] = return ()
1561+ tryUnify env ((nm, ty) : ts)
1562+ = do inj <- get_inj
1563+ hs <- get_holes
1564+ case unify (tt_ctxt ist) env (ty, Nothing) (goal, Nothing)
1565+ inj hs [] [] of
1566+ OK _ ->
1567+ updateAux (\est -> est { implicit_warnings =
1568+ (fc, nm) : implicit_warnings est })
1569+ _ -> tryUnify env ts
1570+
15521571-- For every alternative, look at the function at the head. Automatically resolve
15531572-- any nested alternatives where that function is also at the head
15541573