diff options
| author | Hugo Herbelin | 2020-12-02 17:22:16 +0100 |
|---|---|---|
| committer | Hugo Herbelin | 2020-12-09 11:04:47 +0100 |
| commit | dc7a4f056d97c43badaa6ca5901eafb951527d88 (patch) | |
| tree | 699360da8a42aa36faab86139b9dd64c138c8ade /pretyping/cases.ml | |
| parent | a33172c4f781f7ea2e7420aad9ffb5cfe077d66d (diff) | |
Using self-documenting argument names in two exceptions of cases.ml.
Namely, WrongNumargInductive and WrongNumargConstructor.
Diffstat (limited to 'pretyping/cases.ml')
| -rw-r--r-- | pretyping/cases.ml | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pretyping/cases.ml b/pretyping/cases.ml index 14417d15c6..d2859b1b4e 100644 --- a/pretyping/cases.ml +++ b/pretyping/cases.ml @@ -46,8 +46,10 @@ module NamedDecl = Context.Named.Declaration type pattern_matching_error = | BadPattern of constructor * constr | BadConstructor of constructor * inductive - | WrongNumargConstructor of constructor * bool * int * int * int - | WrongNumargInductive of inductive * bool * int * int * int + | WrongNumargConstructor of + {cstr:constructor; expanded:bool; nargs:int; expected_nassums:int; expected_ndecls:int} + | WrongNumargInductive of + {ind:inductive; expanded:bool; nargs:int; expected_nassums:int; expected_ndecls:int} | UnusedClause of cases_pattern list | NonExhaustive of cases_pattern list | CannotInferPredicate of (constr * types) array @@ -65,11 +67,13 @@ let error_bad_constructor ?loc env cstr ind = raise_pattern_matching_error ?loc (env, Evd.empty, BadConstructor (cstr,ind)) -let error_wrong_numarg_constructor ?loc env c expanded n n1 n2 = - raise_pattern_matching_error ?loc (env, Evd.empty, WrongNumargConstructor(c,expanded,n,n1,n2)) +let error_wrong_numarg_constructor ?loc env ~cstr ~expanded ~nargs ~expected_nassums ~expected_ndecls = + raise_pattern_matching_error ?loc (env, Evd.empty, + WrongNumargConstructor {cstr; expanded; nargs; expected_nassums; expected_ndecls}) -let error_wrong_numarg_inductive ?loc env c expanded n n1 n2 = - raise_pattern_matching_error ?loc (env, Evd.empty, WrongNumargInductive(c,expanded,n,n1,n2)) +let error_wrong_numarg_inductive ?loc env ~ind ~expanded ~nargs ~expected_nassums ~expected_ndecls = + raise_pattern_matching_error ?loc (env, Evd.empty, + WrongNumargInductive {ind; expanded; nargs; expected_nassums; expected_ndecls}) let list_try_compile f l = let rec aux errors = function @@ -528,8 +532,9 @@ let check_and_adjust_constructor env ind cstrs pat = match DAst.get pat with with NotAdjustable -> let nlet = List.count (function LocalDef _ -> true | _ -> false) ci.cs_args in (* In practice, this is already checked at interning *) - error_wrong_numarg_constructor ?loc env cstr - (* as if not expanded: *) false nargs nb_args_constr (nb_args_constr + nlet) + error_wrong_numarg_constructor ?loc env ~cstr + (* as if not expanded: *) ~expanded:false ~nargs ~expected_nassums:nb_args_constr + ~expected_ndecls:(nb_args_constr + nlet) else (* Try to insert a coercion *) try |
