Skip to content

Commit 3b58e1c

Browse files
committed
[ test ] Add test for 0 proof in elaborator script
1 parent e6d6114 commit 3b58e1c

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module WithProof0ElabFail
2+
3+
import Language.Reflection
4+
5+
%default total
6+
7+
%language ElabReflection
8+
9+
%hide List.filter
10+
11+
data So : Bool -> Type where
12+
Oh : So True
13+
14+
eqToSo : b = True -> So b
15+
eqToSo Refl = Oh
16+
17+
data All : (0 p : a -> Type) -> List a -> Type where
18+
Nil : All p Nil
19+
(::) : {0 xs : List a} -> p x -> All p xs -> All p (x :: xs)
20+
21+
filter : (p : a -> Bool) -> (xs : List a) -> List a
22+
filter p [] = []
23+
filter p (x :: xs) with (p x)
24+
filter p (x :: xs) | False = filter p xs
25+
filter p (x :: xs) | True = x :: filter p xs
26+
27+
failing "While processing right hand side of with block in allFilter. prf is not accessible in this context"
28+
%runElab declare `[
29+
allFilter : (p : a -> Bool) -> (xs : List a) -> All (So . p) (filter p xs)
30+
allFilter p [] = []
31+
allFilter p (x :: xs) with (p x) proof 0 prf
32+
allFilter p (x :: xs) | False = allFilter p xs
33+
allFilter p (x :: xs) | True = eqToSo prf :: allFilter p xs
34+
]

tests/idris2/with/with012/expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
1/1: Building WithProof1 (WithProof1.idr)
33
1/1: Building WithProof0Fail (WithProof0Fail.idr)
44
1/1: Building WithProof1Fail (WithProof1Fail.idr)
5+
1/1: Building WithProof0ElabFail (WithProof0ElabFail.idr)

tests/idris2/with/with012/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ check WithProof0.idr
44
check WithProof1.idr
55
check WithProof0Fail.idr
66
check WithProof1Fail.idr
7+
check WithProof0ElabFail.idr

0 commit comments

Comments
 (0)