on master help sign in
Generate cases for coverage from 'impossible'
8b1502aEdwin Brady
src/Idris/Coverage.hs+7−1
@@ -40,6 +40,12 @@ mkPatTm t = do i <- getIState
40 toTT (PApp _ t args) = do t' <- toTT t
40 toTT (PApp _ t args) = do t' <- toTT t
41 args' <- mapM (toTT . getTm) args
41 args' <- mapM (toTT . getTm) args
42 return $ mkApp t' args'
42 return $ mkApp t' args'
43+ toTT (PDPair _ _ _ l _ r) = do l' <- toTT l
44+ r' <- toTT r
45+ return $ mkApp (P Ref sigmaCon Erased) [Erased, Erased, l', r']
46+ toTT (PPair _ _ _ l r) = do l' <- toTT l
47+ r' <- toTT r
48+ return $ mkApp (P Ref pairCon Erased) [Erased, Erased, l', r']
43 -- For alternatives, pick the first and drop the namespaces. It doesn't
49 -- For alternatives, pick the first and drop the namespaces. It doesn't
44 -- really matter which is taken since matching will ignore the namespace.
50 -- really matter which is taken since matching will ignore the namespace.
45 toTT (PAlternative _ _ (a : as)) = toTT a
51 toTT (PAlternative _ _ (a : as)) = toTT a
@@ -78,7 +84,7 @@ genClauses fc n xs given
78 logCoverage 5 $ show (map length argss) ++ "\n" ++ show (map length all_args)
84 logCoverage 5 $ show (map length argss) ++ "\n" ++ show (map length all_args)
79 logCoverage 10 $ show argss ++ "\n" ++ show all_args
85 logCoverage 10 $ show argss ++ "\n" ++ show all_args
80 logCoverage 3 $ "Original: \n" ++
86 logCoverage 3 $ "Original: \n" ++
81− showSep "\n" (map (\t -> showTm i (delab' i t True True)) xs)
87+ showSep "\n" (map (\t -> showTmImpls (delab' i t True True)) xs)
82 -- add an infinite supply of explicit arguments to update the possible
88 -- add an infinite supply of explicit arguments to update the possible
83 -- cases for (the return type may be variadic, or function type, so
89 -- cases for (the return type may be variadic, or function type, so
84 -- there may be more case splitting that the idris_implicits record
90 -- there may be more case splitting that the idris_implicits record
src/Idris/Elab/Clause.hs+2
@@ -539,6 +539,8 @@ elabClause info opts (_, PClause fc fname lhs_in [] PImpossible [])
539 True -> tclift $ tfail (At fc
539 True -> tclift $ tfail (At fc
540 (Msg $ show lhs_in ++ " is a valid case"))
540 (Msg $ show lhs_in ++ " is a valid case"))
541 False -> do ptm <- mkPatTm lhs_in
541 False -> do ptm <- mkPatTm lhs_in
542+ logElab 5 $ "Elaborated impossible case " ++ showTmImpls lhs ++
543+ "\n" ++ show ptm
542 return (Left ptm, lhs)
544 return (Left ptm, lhs)
543elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as whereblock)
545elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as whereblock)
544 = do let tcgen = Dictionary `elem` opts
546 = do let tcgen = Dictionary `elem` opts