@@ -87,7 +87,7 @@ elabClauses info' fc opts n_in cs =
87 let pats_raw = map (simple_lhs ctxt) pats_in
87 let pats_raw = map (simple_lhs ctxt) pats_in
88 logElab 3 $ "Elaborated patterns:\n" ++ show pats_raw
88 logElab 3 $ "Elaborated patterns:\n" ++ show pats_raw
90− solveDeferred n
90+ solveDeferred fc n
92 -- just ensure that the structure exists
92 -- just ensure that the structure exists
93 fmodifyState (ist_optimisation n) id
93 fmodifyState (ist_optimisation n) id
@@ -670,7 +670,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
670 logElab 2 $ "RHS: " ++ show (map fst newargs_all) ++ " " ++ showTmImpls rhs
670 logElab 2 $ "RHS: " ++ show (map fst newargs_all) ++ " " ++ showTmImpls rhs
671 ctxt <- getContext -- new context with where block added
671 ctxt <- getContext -- new context with where block added
672 logElab 5 "STARTING CHECK"
672 logElab 5 "STARTING CHECK"
673− ((rhs', defer, is, probs, ctxt', newDecls, highlights), _) <-
673+ ((rhs', defer, holes, is, probs, ctxt', newDecls, highlights), _) <-
674 tclift $ elaborate ctxt (idris_datatypes i) (sMN 0 "patRHS") clhsty initEState
674 tclift $ elaborate ctxt (idris_datatypes i) (sMN 0 "patRHS") clhsty initEState
675 (do pbinds ist lhs_tm
675 (do pbinds ist lhs_tm
676 -- proof search can use explicitly written names
676 -- proof search can use explicitly written names
@@ -687,7 +687,8 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
687 let (tm, ds) = runState (collectDeferred (Just fname)
687 let (tm, ds) = runState (collectDeferred (Just fname)
688 (map fst $ case_decls aux) ctxt tt) []
688 (map fst $ case_decls aux) ctxt tt) []
689 probs <- get_probs
689 probs <- get_probs
690− return (tm, ds, is, probs, ctxt', newDecls, highlights))
691+ return (tm, ds, hs, is, probs, ctxt', newDecls, highlights))
691 setContext ctxt'
692 setContext ctxt'
692 processTacticDecls info newDecls
693 processTacticDecls info newDecls
693 sendHighlighting highlights
694 sendHighlighting highlights
@@ -698,9 +699,12 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
698 logElab 4 $ "---> " ++ show rhs'
699 logElab 4 $ "---> " ++ show rhs'
699 when (not (null defer)) $ logElab 1 $ "DEFERRED " ++
700 when (not (null defer)) $ logElab 1 $ "DEFERRED " ++
700 show (map (\ (n, (_,_,t,_)) -> (n, t)) defer)
701 show (map (\ (n, (_,_,t,_)) -> (n, t)) defer)
703+ -- If there's holes, set the metavariables as undefinable
701− def' <- checkDef fc (\n -> Elaborating "deferred type of " n Nothing) defer
704+ def' <- checkDef fc (\n -> Elaborating "deferred type of " n Nothing) (null holes) defer
702− let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
705+ let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, null holes))) def'
703 addDeferred def''
706 addDeferred def''
704 mapM_ (\(n, _) -> addIBC (IBCDef n)) def''
708 mapM_ (\(n, _) -> addIBC (IBCDef n)) def''
706 when (not (null def')) $ do
710 when (not (null def')) $ do
@@ -716,11 +720,23 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
716 logElab 5 $ "Rechecking"
720 logElab 5 $ "Rechecking"
717 logElab 6 $ " ==> " ++ show (forget rhs')
721 logElab 6 $ " ==> " ++ show (forget rhs')
719− (crhs, crhsty) <- if not inf
723+ (crhs, crhsty) -- if there's holes && deferred things, it's okay
724+ -- but we'll need to freeze the definition and not
725+ -- allow the deferred things to be definable
726+ -- (this is just to allow users to inspect intermediate
728+ <- if (null holes || null def') && not inf
720− then recheckC_borrowing True (PEGenerated `notElem` opts)
729+ then recheckC_borrowing True (PEGenerated `notElem` opts)
721− borrowed fc id [] rhs'
730+ borrowed fc id [] rhs'
722− else return (rhs', clhsty)
731+ else return (rhs', clhsty)
723 logElab 6 $ " ==> " ++ showEnvDbg [] crhsty ++ " against " ++ showEnvDbg [] clhsty
733 logElab 6 $ " ==> " ++ showEnvDbg [] crhsty ++ " against " ++ showEnvDbg [] clhsty
735+ -- If there's holes, make sure this definition is frozen
736+ when (not (null holes)) $ do
737+ logElab 5 $ "Making " ++ show fname ++ " frozen due to " ++ show holes
738+ setAccessibility fname Frozen
724 ctxt <- getContext
740 ctxt <- getContext
725 let constv = next_tvar ctxt
741 let constv = next_tvar ctxt
726 case LState.runStateT (convertsC ctxt [] crhsty clhsty) (constv, []) of
742 case LState.runStateT (convertsC ctxt [] crhsty clhsty) (constv, []) of
@@ -861,7 +877,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
861 processTacticDecls info newDecls
877 processTacticDecls info newDecls
862 sendHighlighting highlights
878 sendHighlighting highlights
864− def' <- checkDef fc iderr defer
880+ def' <- checkDef fc iderr True defer
865 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
881 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
866 addDeferred def''
882 addDeferred def''
867 mapM_ (elabCaseBlock info opts) is
883 mapM_ (elabCaseBlock info opts) is
@@ -926,7 +942,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
926 addIBC (IBCImp wname)
942 addIBC (IBCImp wname)
927 addIBC (IBCStatic wname)
943 addIBC (IBCStatic wname)
929− def' <- checkDef fc iderr [(wname, (-1, Nothing, wtype, []))]
945+ def' <- checkDef fc iderr True [(wname, (-1, Nothing, wtype, []))]
930 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
946 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
931 addDeferred def''
947 addDeferred def''
@@ -967,7 +983,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
967 processTacticDecls info newDecls
983 processTacticDecls info newDecls
968 sendHighlighting highlights
984 sendHighlighting highlights
970− def' <- checkDef fc iderr defer
986+ def' <- checkDef fc iderr True defer
971 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
987 let def'' = map (\(n, (i, top, t, ns)) -> (n, (i, top, t, ns, False, True))) def'
972 addDeferred def''
988 addDeferred def''
973 mapM_ (elabCaseBlock info opts) is
989 mapM_ (elabCaseBlock info opts) is