List.nth il indtype_no
with _ -> assert false
in
+ let rec count_prod t =
+ match CicReduction.whd [] t with
+ Cic.Prod (_, _, t) -> 1 + (count_prod t)
+ | _ -> 0
+ in
let rec sort branches cl =
match cl with
[] ->
("Unrecognized constructors: " ^
String.concat " "
(List.map (fun ((head,_,_),_) -> head) branches))))
- | (name,_)::cltl ->
+ | (name,ty)::cltl ->
let rec find_and_remove =
function
[] ->
found, branch::rest
in
let branch,tl = find_and_remove branches in
- branch::sort tl cltl
+ let (_,_,args),_ = branch in
+ if List.length args = count_prod ty then
+ branch::sort tl cltl
+ else
+ raise
+ (Invalid_choice
+ (Some loc,
+ lazy ("Wrong number of arguments for " ^ name)))
in
sort branches cl
| _ -> assert false