@@ -497,7 +497,7 @@ checkPossible info fc tcgen fname lhs_in
497 i <- getIState
497 i <- getIState
498 let lhs = addImplPat i lhs_in
498 let lhs = addImplPat i lhs_in
499 -- if the LHS type checks, it is possible
499 -- if the LHS type checks, it is possible
500− case elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
500+ case elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
501 (erun fc (buildTC i info ELHS [] fname
501 (erun fc (buildTC i info ELHS [] fname
502 (allNamesIn lhs_in)
502 (allNamesIn lhs_in)
503 (infTerm lhs))) of
503 (infTerm lhs))) of
@@ -507,7 +507,7 @@ checkPossible info fc tcgen fname lhs_in
507 sendHighlighting highlights
507 sendHighlighting highlights
508 updateIState $ \i -> i { idris_name = newGName }
508 updateIState $ \i -> i { idris_name = newGName }
509 let lhs_tm = orderPats (getInferTerm lhs')
509 let lhs_tm = orderPats (getInferTerm lhs')
510− case recheck ctxt' [] (forget lhs_tm) lhs_tm of
510+ case recheck (constraintNS info) ctxt' [] (forget lhs_tm) lhs_tm of
511 OK _ -> return True
511 OK _ -> return True
512 err -> return False
512 err -> return False
513 -- if it's a recoverable error, the case may become possible
513 -- if it's a recoverable error, the case may become possible
@@ -580,7 +580,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
580 "\n" ++ show (fn_ty, fn_is))
580 "\n" ++ show (fn_ty, fn_is))
582 ((ElabResult lhs' dlhs [] ctxt' newDecls highlights newGName, probs, inj), _) <-
582 ((ElabResult lhs' dlhs [] ctxt' newDecls highlights newGName, probs, inj), _) <-
583− tclift $ elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
583+ tclift $ elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
584 (do res <- errAt "left hand side of " fname Nothing
584 (do res <- errAt "left hand side of " fname Nothing
585 (erun fc (buildTC i info ELHS opts fname
585 (erun fc (buildTC i info ELHS opts fname
586 (allNamesIn lhs_in)
586 (allNamesIn lhs_in)
@@ -608,7 +608,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
608 ctxt <- getContext
608 ctxt <- getContext
609 (clhs_c, clhsty) <- if not inf
609 (clhs_c, clhsty) <- if not inf
610 then recheckC_borrowing False (PEGenerated `notElem` opts)
610 then recheckC_borrowing False (PEGenerated `notElem` opts)
611− [] fc id [] lhs_tm
611+ [] (constraintNS info) fc id [] lhs_tm
612 else return (lhs_tm, lhs_ty)
612 else return (lhs_tm, lhs_ty)
613 let clhs = Idris.Core.Evaluate.simplify ctxt [] clhs_c
613 let clhs = Idris.Core.Evaluate.simplify ctxt [] clhs_c
614 let borrowed = borrowedNames [] clhs
614 let borrowed = borrowedNames [] clhs
@@ -666,7 +666,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
666 ctxt <- getContext -- new context with where block added
666 ctxt <- getContext -- new context with where block added
667 logElab 5 "STARTING CHECK"
667 logElab 5 "STARTING CHECK"
668 ((rhs', defer, holes, is, probs, ctxt', newDecls, highlights, newGName), _) <-
668 ((rhs', defer, holes, is, probs, ctxt', newDecls, highlights, newGName), _) <-
669− tclift $ elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patRHS") clhsty initEState
669+ tclift $ elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patRHS") clhsty initEState
670 (do pbinds ist lhs_tm
670 (do pbinds ist lhs_tm
671 -- proof search can use explicitly written names
671 -- proof search can use explicitly written names
672 mapM_ addPSname (allNamesIn lhs_in)
672 mapM_ addPSname (allNamesIn lhs_in)
@@ -697,7 +697,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
697 show (map (\ (n, (_,_,t,_)) -> (n, t)) defer)
697 show (map (\ (n, (_,_,t,_)) -> (n, t)) defer)
699 -- If there's holes, set the metavariables as undefinable
699 -- If there's holes, set the metavariables as undefinable
700− def' <- checkDef fc (\n -> Elaborating "deferred type of " n Nothing) (null holes) defer
700+ def' <- checkDef info fc (\n -> Elaborating "deferred type of " n Nothing) (null holes) defer
701 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, null holes))) def'
701 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, null holes))) def'
702 addDeferred def''
702 addDeferred def''
@@ -723,7 +723,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
723 -- things)
723 -- things)
724 <- if (null holes || null def') && not inf
724 <- if (null holes || null def') && not inf
725 then recheckC_borrowing True (PEGenerated `notElem` opts)
725 then recheckC_borrowing True (PEGenerated `notElem` opts)
726− borrowed fc id [] rhs'
726+ borrowed (constraintNS info) fc id [] rhs'
727 else return (rhs', clhsty)
727 else return (rhs', clhsty)
729 logElab 6 $ " ==> " ++ showEnvDbg [] crhsty ++ " against " ++ showEnvDbg [] clhsty
729 logElab 6 $ " ==> " ++ showEnvDbg [] crhsty ++ " against " ++ showEnvDbg [] clhsty
@@ -738,6 +738,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
738 case LState.runStateT (convertsC ctxt [] crhsty clhsty) (constv, []) of
738 case LState.runStateT (convertsC ctxt [] crhsty clhsty) (constv, []) of
739 OK (_, cs) -> when (PEGenerated `notElem` opts) $ do
739 OK (_, cs) -> when (PEGenerated `notElem` opts) $ do
740 addConstraints fc cs
740 addConstraints fc cs
741+ mapM_ (\c -> addIBC (IBCConstraint fc c)) (snd cs)
741 logElab 6 $ "CONSTRAINTS ADDED: " ++ show cs ++ "\n" ++ show (clhsty, crhsty)
742 logElab 6 $ "CONSTRAINTS ADDED: " ++ show cs ++ "\n" ++ show (clhsty, crhsty)
742 return ()
743 return ()
743 Error e -> ierror (At fc (CantUnify False (clhsty, Nothing) (crhsty, Nothing) e [] 0))
744 Error e -> ierror (At fc (CantUnify False (clhsty, Nothing) (crhsty, Nothing) e [] 0))
@@ -832,7 +833,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
832 (addImplPat i lhs_in)
833 (addImplPat i lhs_in)
833 logElab 2 ("LHS: " ++ show lhs)
834 logElab 2 ("LHS: " ++ show lhs)
834 (ElabResult lhs' dlhs [] ctxt' newDecls highlights newGName, _) <-
835 (ElabResult lhs' dlhs [] ctxt' newDecls highlights newGName, _) <-
835− tclift $ elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
836+ tclift $ elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "patLHS") infP initEState
836 (errAt "left hand side of with in " fname Nothing
837 (errAt "left hand side of with in " fname Nothing
837 (erun fc (buildTC i info ELHS opts fname
838 (erun fc (buildTC i info ELHS opts fname
838 (allNamesIn lhs_in)
839 (allNamesIn lhs_in)
@@ -848,14 +849,14 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
848 let ret_ty = getRetTy (explicitNames (normalise ctxt [] lhs_ty))
849 let ret_ty = getRetTy (explicitNames (normalise ctxt [] lhs_ty))
849 let static_names = getStaticNames i lhs_tm
850 let static_names = getStaticNames i lhs_tm
850 logElab 5 (show lhs_tm ++ "\n" ++ show static_names)
851 logElab 5 (show lhs_tm ++ "\n" ++ show static_names)
851− (clhs, clhsty) <- recheckC fc id [] lhs_tm
852+ (clhs, clhsty) <- recheckC (constraintNS info) fc id [] lhs_tm
852 logElab 5 ("Checked " ++ show clhs)
853 logElab 5 ("Checked " ++ show clhs)
853 let bargs = getPBtys (explicitNames (normalise ctxt [] lhs_tm))
854 let bargs = getPBtys (explicitNames (normalise ctxt [] lhs_tm))
854 let wval = rhs_trans info $ addImplBound i (map fst bargs) wval_in
855 let wval = rhs_trans info $ addImplBound i (map fst bargs) wval_in
855 logElab 5 ("Checking " ++ showTmImpls wval)
856 logElab 5 ("Checking " ++ showTmImpls wval)
856 -- Elaborate wval in this context
857 -- Elaborate wval in this context
857 ((wval', defer, is, ctxt', newDecls, highlights, newGName), _) <-
858 ((wval', defer, is, ctxt', newDecls, highlights, newGName), _) <-
858− tclift $ elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "withRHS")
859+ tclift $ elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "withRHS")
859 (bindTyArgs PVTy bargs infP) initEState
860 (bindTyArgs PVTy bargs infP) initEState
860 (do pbinds i lhs_tm
861 (do pbinds i lhs_tm
861 -- proof search can use explicitly written names
862 -- proof search can use explicitly written names
@@ -872,14 +873,14 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
872 sendHighlighting highlights
873 sendHighlighting highlights
873 updateIState $ \i -> i { idris_name = newGName }
874 updateIState $ \i -> i { idris_name = newGName }
875− def' <- checkDef fc iderr True defer
876+ def' <- checkDef info fc iderr True defer
876 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
877 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
877 addDeferred def''
878 addDeferred def''
878 mapM_ (elabCaseBlock info opts) is
879 mapM_ (elabCaseBlock info opts) is
879 logElab 5 ("Checked wval " ++ show wval')
880 logElab 5 ("Checked wval " ++ show wval')
881 ctxt <- getContext
882 ctxt <- getContext
882− (cwval, cwvalty) <- recheckC fc id [] (getInferTerm wval')
883+ (cwval, cwvalty) <- recheckC (constraintNS info) fc id [] (getInferTerm wval')
883 let cwvaltyN = explicitNames (normalise ctxt [] cwvalty)
884 let cwvaltyN = explicitNames (normalise ctxt [] cwvalty)
884 let cwvalN = explicitNames (normalise ctxt [] cwval)
885 let cwvalN = explicitNames (normalise ctxt [] cwval)
885 logElab 3 ("With type " ++ show cwvalty ++ "\nRet type " ++ show ret_ty)
886 logElab 3 ("With type " ++ show cwvalty ++ "\nRet type " ++ show ret_ty)
@@ -914,7 +915,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
914 let wargname = sMN windex "warg"
915 let wargname = sMN windex "warg"
916 logElab 5 ("Abstract over " ++ show wargval ++ " in " ++ show wargtype)
917 logElab 5 ("Abstract over " ++ show wargval ++ " in " ++ show wargtype)
917− let wtype = bindTyArgs (flip (Pi Nothing) (TType (UVar 0))) (bargs_pre ++
918+ let wtype = bindTyArgs (flip (Pi Nothing) (TType (UVar [] 0))) (bargs_pre ++
918 (wargname, wargtype) :
919 (wargname, wargtype) :
919 map (abstract wargname wargval wargtype) bargs_post ++
920 map (abstract wargname wargval wargtype) bargs_post ++
920 case mpn of
921 case mpn of
@@ -937,7 +938,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
937 addIBC (IBCImp wname)
938 addIBC (IBCImp wname)
938 addIBC (IBCStatic wname)
939 addIBC (IBCStatic wname)
940− def' <- checkDef fc iderr True [(wname, (-1, Nothing, wtype, []))]
941+ def' <- checkDef info fc iderr True [(wname, (-1, Nothing, wtype, []))]
941 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
942 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
942 addDeferred def''
943 addDeferred def''
@@ -970,7 +971,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
970 ctxt <- getContext -- New context with block added
971 ctxt <- getContext -- New context with block added
971 i <- getIState
972 i <- getIState
972 ((rhs', defer, is, ctxt', newDecls, highlights, newGName), _) <-
973 ((rhs', defer, is, ctxt', newDecls, highlights, newGName), _) <-
973− tclift $ elaborate ctxt (idris_datatypes i) (idris_name i) (sMN 0 "wpatRHS") clhsty initEState
974+ tclift $ elaborate (constraintNS info) ctxt (idris_datatypes i) (idris_name i) (sMN 0 "wpatRHS") clhsty initEState
974 (do pbinds i lhs_tm
975 (do pbinds i lhs_tm
975 setNextName
976 setNextName
976 (ElabResult _ d is ctxt' newDecls highlights newGName) <-
977 (ElabResult _ d is ctxt' newDecls highlights newGName) <-
@@ -983,12 +984,12 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
983 sendHighlighting highlights
984 sendHighlighting highlights
984 updateIState $ \i -> i { idris_name = newGName }
985 updateIState $ \i -> i { idris_name = newGName }
986− def' <- checkDef fc iderr True defer
987+ def' <- checkDef info fc iderr True defer
987 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
988 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
988 addDeferred def''
989 addDeferred def''
989 mapM_ (elabCaseBlock info opts) is
990 mapM_ (elabCaseBlock info opts) is
990 logElab 5 ("Checked RHS " ++ show rhs')
991 logElab 5 ("Checked RHS " ++ show rhs')
991− (crhs, crhsty) <- recheckC fc id [] rhs'
992+ (crhs, crhsty) <- recheckC (constraintNS info) fc id [] rhs'
992 return $ (Right (clhs, crhs), lhs)
993 return $ (Right (clhs, crhs), lhs)
994 getImps (Bind n (Pi _ _ _) t) = pexp Placeholder : getImps t
995 getImps (Bind n (Pi _ _ _) t) = pexp Placeholder : getImps t