diff options
-rw-r--r-- | test-suite/output/Arguments_renaming.out | 10 | ||||
-rw-r--r-- | test-suite/output/Arguments_renaming.v | 2 | ||||
-rw-r--r-- | toplevel/vernacentries.ml | 12 |
3 files changed, 13 insertions, 11 deletions
diff --git a/test-suite/output/Arguments_renaming.out b/test-suite/output/Arguments_renaming.out index 9d90de47c..b084ad498 100644 --- a/test-suite/output/Arguments_renaming.out +++ b/test-suite/output/Arguments_renaming.out @@ -1,6 +1,5 @@ The command has indeed failed with message: -Error: To rename arguments the "rename" flag must be -specified. +Error: To rename arguments the "rename" flag must be specified. Argument A renamed to B. File "stdin", line 2, characters 0-25: Warning: This command is just asserting the names of arguments of identity. @@ -104,16 +103,15 @@ Expands to: Constant Top.myplus @myplus : forall Z : Type, Z -> nat -> nat -> nat The command has indeed failed with message: -Error: Arguments lists should agree on names they provide. +Error: Argument lists should agree on the names they provide. The command has indeed failed with message: Error: Sequences of implicit arguments must be of different lengths. The command has indeed failed with message: -Error: Arguments names must be distinct. +Error: Some argument names are duplicated: F The command has indeed failed with message: Error: Argument z cannot be declared implicit. The command has indeed failed with message: Error: Extra arguments: y. The command has indeed failed with message: -Error: To rename arguments the "rename" flag must be -specified. +Error: To rename arguments the "rename" flag must be specified. Argument A renamed to R. diff --git a/test-suite/output/Arguments_renaming.v b/test-suite/output/Arguments_renaming.v index 2d14c94ac..0cb331347 100644 --- a/test-suite/output/Arguments_renaming.v +++ b/test-suite/output/Arguments_renaming.v @@ -47,7 +47,7 @@ Check @myplus. Fail Arguments eq_refl {F g}, [H] k. Fail Arguments eq_refl {F}, [F] : rename. -Fail Arguments eq_refl {F F}, [F] F. +Fail Arguments eq_refl {F F}, [F] F : rename. Fail Arguments eq {F} x [z] : rename. Fail Arguments eq {F} x z y. Fail Arguments eq {R} s t. diff --git a/toplevel/vernacentries.ml b/toplevel/vernacentries.ml index ef530d590..851d7557a 100644 --- a/toplevel/vernacentries.ml +++ b/toplevel/vernacentries.ml @@ -1082,7 +1082,7 @@ let vernac_arguments locality reference args more_implicits nargs_for_red flags | name1 :: names1, name2 :: names2 -> if Name.equal name1 name2 then name1 :: names_union names1 names2 - else error "Arguments lists should agree on names they provide." + else error "Argument lists should agree on the names they provide." in let initial = List.make num_args Anonymous in @@ -1107,9 +1107,6 @@ let vernac_arguments locality reference args more_implicits nargs_for_red flags let names = rename prev_names names in let renaming_specified = Option.has_some !example_renaming in - if not (List.distinct_f Name.compare (List.filter ((!=) Anonymous) names)) then - error "Arguments names must be distinct."; - if !rename_flag_required && not rename_flag then errorlabstrm "vernac_declare_arguments" (strbrk "To rename arguments the \"rename\" flag must be specified." @@ -1120,6 +1117,13 @@ let vernac_arguments locality reference args more_implicits nargs_for_red flags str "\nArgument " ++ pr_name o ++ str " renamed to " ++ pr_name n ++ str "."); + let duplicate_names = + List.duplicates Name.equal (List.filter ((!=) Anonymous) names) + in + if not (List.is_empty duplicate_names) then begin + let duplicates = prlist_with_sep pr_comma pr_name duplicate_names in + errorlabstrm "_" (strbrk "Some argument names are duplicated: " ++ duplicates) + end; (* Parts of this code are overly complicated because the implicit arguments API is completely crazy: positions (ExplByPos) are elaborated to |