on master help sign in
Allow programs with holes to be compiled

This means incomplete programs can be compiled and tested. There will be a warning at compile time, and evaluating an expression with a hole will cause the program to abort at run time.

commitc6ec8088d2bc179b4999566b6e089631a4e65ec4 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateThu 24 Mar 2016, 15:06 (11 years ago) parent3bb24be
2 files changed+9−1
CHANGELOG+2 src/IRTS/Compiler.hs+7−1
CHANGELOG+2
@@ -79,6 +79,8 @@ Minor language changes
7979* More flexible holes.
8080 Holes can now depend on other holes in a term (such as implicit arguments
8181 which may be inferred from the definition of the hole).
82+* Programs with holes can now be compiled.
83+ Attempting to evaluate an expression with a hole results in a run time error.
8284
8385New in 0.10:
8486============
src/IRTS/Compiler.hs+7−1
@@ -18,6 +18,7 @@ import Idris.AbsSyntaxTree
1818import Idris.ASTUtils
1919import Idris.Erasure
2020import Idris.Error
21+import Idris.Output
2122
2223import Debug.Trace
2324
@@ -112,7 +113,9 @@ compile codegen f mtm
112113 where checkMVs = do i <- getIState
113114 case map fst (idris_metavars i) \\ primDefs of
114115 [] -> return ()
115− ms -> ifail $ "There are undefined holes: " ++ show ms
116+ ms -> do iputStrLn $ "WARNING: There are incomplete holes:\n " ++ show ms
117+ iputStrLn "\nEvaluation of any of these will crash at run time."
118+ return ()
116119 checkTotality = do i <- getIState
117120 case idris_totcheckfail i of
118121 [] -> return ()
@@ -227,6 +230,9 @@ irTerm :: Vars -> [Name] -> Term -> Idris LExp
227230irTerm vs env tm@(App _ f a) = do
228231 ist <- getIState
229232 case unApply tm of
233+ (P _ n _, args)
234+ | n `elem` map fst (idris_metavars ist) \\ primDefs
235+ -> return $ LError $ "ABORT: Attempt to evaluate hole " ++ show n
230236 (P _ (UN m) _, args)
231237 | m == txt "mkForeignPrim"
232238 -> doForeign vs env (reverse (drop 4 args)) -- drop implicits