Debian Codegraph @

test-suite/bugs/bug_5500.v

raw
1 (* Too weak check on the correctness of return clause was leading to an anomaly *)
2
3 Inductive Vector A: nat -> Type :=
4 nil: Vector A O
5 | cons: forall n, A -> Vector A n -> Vector A (S n).
6
7 (* This could be made working with a better inference of inner return
8 predicates from the return predicate at the higher level of the
9 nested matching. Currently, we only check that it does not raise an
10 anomaly, but eventually, the "Fail" could be removed. *)
11
12 Fail Definition hd_fst A x n (v: A * Vector A (S n)) :=
13 match v as v0 return match v0 with
14 (l, r) =>
15 match r in Vector _ n return match n with 0 => Type | S _ => Type end with
16 nil _ => A
17 | cons _ _ _ _ => A
18 end
19 end with
20 (_, nil _) => x
21 | (_, cons _ n hd tl) => hd
22 end.
23
24 (* This is another example of failure but involving beta-reduction and
25 not iota-reduction. Thus, for this one, I don't see how it could be
26 solved by small inversion, whatever smart is small inversion. *)
27
28 Inductive A : (Type->Type) -> Type := J : A (fun x => x).
29
30 Fail Check fun x : nat * A (fun x => x) =>
31 match x return match x with
32 (y,z) => match z in A f return f Type with J => bool end
33 end with
34 (y,J) => true
35 end.