on master help sign in
Merge pull request #1215 from david-christiansen/totality

Stop building packages if there are totality mismatches

commita5669f0f98133d9256e1ed9de91175cd3b0fdd6e authorEdwin Brady <edwin.brady@gmail.com> dateSat 10 May 2014, 12:30 (12 years ago) parente1f75978d07967
6 files changed+28−2
idris.cabal+4 src/Idris/REPL.hs+7−2 test/totality007/expected+3 test/totality007/run+3 test/totality007/src/Totality.idr+4 test/totality007/totality.ipkg+7
idris.cabal+4
@@ -444,6 +444,10 @@ Extra-source-files:
444444 test/totality006/run
445445 test/totality006/*.idr
446446 test/totality006/expected
447+ test/totality007/run
448+ test/totality007/*.ipkg
449+ test/totality007/src/*.idr
450+ test/totality007/expected
447451
448452 test/tutorial001/run
449453 test/tutorial001/*.idr
src/Idris/REPL.hs+7−2
@@ -1218,13 +1218,18 @@ replSettings hFile = setComplete replCompletion $ defaultSettings {
12181218 historyFile = hFile
12191219 }
12201220
1221−-- invoke as if from command line
1221+-- | Invoke as if from command line. It is an error if there are unresolved totality problems.
12221222idris :: [Opt] -> IO (Maybe IState)
1223−idris opts = do res <- runErrorT $ execStateT (idrisMain opts) idrisInit
1223+idris opts = do res <- runErrorT $ execStateT totalMain idrisInit
12241224 case res of
12251225 Left err -> do putStrLn $ pshow idrisInit err
12261226 return Nothing
12271227 Right ist -> return (Just ist)
1228+ where totalMain = do idrisMain opts
1229+ ist <- getIState
1230+ case idris_totcheckfail ist of
1231+ ((fc, msg):_) -> ierror . At fc . Msg $ "Could not build: "++ msg
1232+ [] -> return ()
12281233
12291234
12301235loadInputs :: Handle -> [FilePath] -> Idris ()
test/totality007/expectednew file+3
@@ -0,0 +1,3 @@
1+Type checking ./Totality.idr
2+Totality.idr:4:1:Totality.foo is not total as there are missing cases
3+Totality.idr:4:1:Could not build: Totality.foo is not total as there are missing cases
test/totality007/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+idris $@ --build totality.ipkg
3+rm -f src/*.ibc
test/totality007/src/Totality.idrnew file+4
@@ -0,0 +1,4 @@
1+module Totality
2+
3+total foo : Nat -> Nat
4+foo Z = Z
test/totality007/totality.ipkgnew file+7
@@ -0,0 +1,7 @@
1+package totality
2+
3+-- totality007
4+-- Test that the package builder doesn't allow totality errors in a build
5+opts = ""
6+sourcedir = src
7+modules = Totality