X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FcicNotationFwd.ml;h=bf4b3e38e7beb17623542f91ed2ec1b2260696c6;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=3ef1ff7e0deada79265cf44c8d6628b231facd5b;hpb=98d5d40127827a5c40e58cb0c9654066f940b0ea;p=helm.git diff --git a/helm/ocaml/cic_notation/cicNotationFwd.ml b/helm/ocaml/cic_notation/cicNotationFwd.ml index 3ef1ff7e0..bf4b3e38e 100644 --- a/helm/ocaml/cic_notation/cicNotationFwd.ml +++ b/helm/ocaml/cic_notation/cicNotationFwd.ml @@ -35,8 +35,7 @@ let unopt_names names env = | Env.OptType ty, Env.OptValue (Some v) -> aux ((name, (ty, v)) :: acc) tl | _ -> assert false) - | _ :: tl -> aux acc tl - (* some pattern may contain only meta names, thus we trash all others *) + | hd :: tl -> aux (hd :: acc) tl | [] -> acc in aux [] env @@ -77,6 +76,7 @@ let instantiate_level2 env term = new_name in let rec aux env term = +(* prerr_endline ("ENV " ^ CicNotationPp.pp_env env); *) match term with | Ast.AttributedTerm (_, term) -> aux env term | Ast.Appl terms -> Ast.Appl (List.map (aux env) terms) @@ -129,7 +129,14 @@ let instantiate_level2 env term = | Ast.Ascription (term, name) -> assert false and aux_magic env = function | Ast.Default (some_pattern, none_pattern) -> - (match CicNotationUtil.names_of_term some_pattern with + let some_pattern_names = CicNotationUtil.names_of_term some_pattern in + let none_pattern_names = CicNotationUtil.names_of_term none_pattern in + let opt_names = + List.filter + (fun name -> not (List.mem name none_pattern_names)) + some_pattern_names + in + (match opt_names with | [] -> assert false (* some pattern must contain at least 1 name *) | (name :: _) as names -> (match Env.lookup_value env name with @@ -139,7 +146,11 @@ let instantiate_level2 env term = *) aux (unopt_names names env) some_pattern | Env.OptValue None -> aux env none_pattern - | _ -> assert false)) + | _ -> + prerr_endline (sprintf + "lookup of %s in env %s did not return an optional value" + name (CicNotationPp.pp_env env)); + assert false)) | Ast.Fold (`Left, base_pattern, names, rec_pattern) -> let acc_name = List.hd names in (* names can't be empty, cfr. parser *) let meta_names =