Idris2/tests/idris2/coverage010/casetot.idr
Edwin Brady 690328421a Delay building references for case blocks
...until the definition is complete. This is necessary since sometimes
information outside the case block can help resolve interfaces, and in
the simplest case, we might just have delayed resolving a default
Integer. It turns out this was also an obscure bug waiting to happen
with coverage checking of nested case blocks (so there's a test update
there too).

Fixes #443
2020-07-18 19:22:03 +01:00

23 lines
529 B
Idris

module Main
import Data.Strings
import Data.Vect
import System
%default total
ints : Vect 4 Int
ints = [1, 2, 3, 4]
main : IO ()
main = do
[_, arg] <- getArgs
| _ => do putStrLn "One argument expected."
exitFailure
let n = stringToNatOrZ arg
-- case block in a case block, which is needed to test this properly
case natToFin n (length ints + 1) of
Nothing => do putStrLn "Invalid number."
exitFailure
Just (FS i) => putStrLn $ "Value: " ++ show (index i ints)