@@ -33,7 +33,7 @@ type error =
33
33
Longident .t * Path .t * Includemod .error list
34
34
| With_changes_module_alias of Longident .t * Ident .t * Path .t
35
35
| With_cannot_remove_constrained_type
36
- | Repeated_name of string * string
36
+ | Repeated_name of string * string * Warnings .loc
37
37
| Non_generalizable of type_expr
38
38
| Non_generalizable_module of module_type
39
39
| Interface_not_compiled of string
@@ -623,25 +623,26 @@ let check_recmod_typedecls env sdecls decls =
623
623
module StringSet =
624
624
Set. Make (struct type t = string let compare (x :t ) y = String. compare x y end )
625
625
626
- let check cl loc set_ref name =
627
- if StringSet. mem name ! set_ref
628
- then raise(Error (loc, Env. empty, Repeated_name (cl, name)))
629
- else set_ref := StringSet. add name ! set_ref
626
+ let check cl loc tbl name =
627
+ match Hashtbl. find_opt tbl name with
628
+ | Some repeated_loc ->
629
+ raise(Error (loc, Env. empty, Repeated_name (cl, name, repeated_loc)))
630
+ | None -> Hashtbl. add tbl name loc
630
631
631
632
type names =
632
633
{
633
- types : StringSet .t ref ;
634
- modules : StringSet .t ref ;
635
- modtypes : StringSet .t ref ;
636
- typexts : StringSet .t ref ;
634
+ types : ( string , Warnings .loc ) Hashtbl .t ;
635
+ modules : ( string , Warnings .loc ) Hashtbl .t ;
636
+ modtypes : ( string , Warnings .loc ) Hashtbl .t ;
637
+ typexts : ( string , Warnings .loc ) Hashtbl .t ;
637
638
}
638
639
639
640
let new_names () =
640
641
{
641
- types = ref StringSet. empty ;
642
- modules = ref StringSet. empty ;
643
- modtypes = ref StringSet. empty ;
644
- typexts = ref StringSet. empty ;
642
+ types = ( Hashtbl. create 10 ) ;
643
+ modules = ( Hashtbl. create 10 ) ;
644
+ modtypes = ( Hashtbl. create 10 ) ;
645
+ typexts = ( Hashtbl. create 10 ) ;
645
646
}
646
647
647
648
@@ -1853,10 +1854,13 @@ let report_error ppf = function
1853
1854
" @[<v>Destructive substitutions are not supported for constrained @ \
1854
1855
types (other than when replacing a type constructor with @ \
1855
1856
a type constructor with the same arguments).@]"
1856
- | Repeated_name (kind , name ) ->
1857
+ | Repeated_name (kind , name , repeated_loc ) ->
1858
+ let start_line = repeated_loc.loc_start.pos_lnum in
1859
+ let start_col = repeated_loc.loc_start.pos_cnum - repeated_loc.loc_start.pos_bol in
1860
+ let end_col = repeated_loc.loc_end.pos_cnum - repeated_loc.loc_end.pos_bol in
1857
1861
fprintf ppf
1858
- " @[Multiple definition of the %s name %s.@ \
1859
- Names must be unique in a given structure or signature.@]" kind name
1862
+ " @[Multiple definition of the %s name %s at line %d, characters %d-%d .@ \
1863
+ Names must be unique in a given structure or signature.@]" kind name start_line start_col end_col
1860
1864
| Non_generalizable typ ->
1861
1865
fprintf ppf
1862
1866
" @[The type of this expression,@ %a,@ \
0 commit comments