@@ -493,7 +493,8 @@ match_fill guess ctxt env (Bind x (Hole ty) sc) =
493493 do (val, valty) <- lift $ check ctxt env guess
494494-- let valtyn = normalise ctxt env valty
495495-- let tyn = normalise ctxt env ty
496− ns <- match_unify' ctxt env (valty, Nothing) (ty, Nothing)
496+ ns <- match_unify' ctxt env (valty, Just $ SourceTerm val)
497+ (ty, Just ExpectedType)
497498 ps <- get
498499 let (uh, uns) = unified ps
499500-- put (ps { unified = (uh, uns ++ ns) })
@@ -511,7 +512,8 @@ complete_fill :: RunTactic
511512complete_fill ctxt env (Bind x (Guess ty val) sc) =
512513 do let guess = forget val
513514 (val', valty) <- lift $ check ctxt env guess
514− ns <- unify' ctxt env (valty, Nothing) (ty, Nothing)
515+ ns <- unify' ctxt env (valty, Just $ SourceTerm val')
516+ (ty, Just ExpectedType)
515517 ps <- get
516518 let (uh, uns) = unified ps
517519-- put (ps { unified = (uh, uns ++ ns) })
@@ -529,7 +531,8 @@ solve ctxt env (Bind x (Guess ty val) sc)
529531 dropdots <-
530532 case lookup x (notunified ps) of
531533 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
532− do match_unify' ctxt env (tm, Nothing) (val, Nothing)
534+ do match_unify' ctxt env (tm, Just InferredVal)
535+ (val, Just GivenVal)
533536 return [x]
534537 _ -> return []
535538 action (\ps -> ps { holes = traceWhen (unifylog ps) ("Dropping hole " ++ show x) $
@@ -822,13 +825,17 @@ updateEnv ns [] = []
822825updateEnv ns ((n, b) : env)
823826 = (n, fmap (updateSolvedTerm ns) b) : updateEnv ns env
824827
828+updateProv ns (SourceTerm t) = SourceTerm $ updateSolvedTerm ns t
829+updateProv ns p = p
830+
825831updateError [] err = err
826832updateError ns (At f e) = At f (updateError ns e)
827833updateError ns (Elaborating s n e) = Elaborating s n (updateError ns e)
828834updateError ns (ElaboratingArg f a env e)
829835 = ElaboratingArg f a env (updateError ns e)
830836updateError ns (CantUnify b (l,lp) (r,rp) e xs sc)
831− = CantUnify b (updateSolvedTerm ns l, lp) (updateSolvedTerm ns r, rp) (updateError ns e) xs sc
837+ = CantUnify b (updateSolvedTerm ns l, fmap (updateProv ns) lp)
838+ (updateSolvedTerm ns r, fmap (updateProv ns) rp) (updateError ns e) xs sc
832839updateError ns e = e
833840
834841solveInProblems x val [] = []