[m-rev.] for review: make mmc -f warn about multiply defined modules
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Apr 2 15:14:08 AEST 2007
On Mon, 2 Apr 2007, Peter Wang wrote:
> Branches: main
>
> compiler/source_file_map.m:
> When generating a source file mapping, warn if a module is defined in
> multiple files.
>
>
> Index: compiler/source_file_map.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/source_file_map.m,v
> retrieving revision 1.20
> diff -u -r1.20 source_file_map.m
> --- compiler/source_file_map.m 1 Dec 2006 15:04:20 -0000 1.20
> +++ compiler/source_file_map.m 1 Apr 2007 09:00:02 -0000
> @@ -55,6 +55,7 @@
> :- import_module dir.
> :- import_module map.
> :- import_module maybe.
> +:- import_module set.
> :- import_module string.
>
> %-----------------------------------------------------------------------------%
> @@ -177,7 +178,8 @@
> io.open_output(ModulesFileName, OpenRes, !IO),
> (
> OpenRes = ok(Stream),
> - list.foldl(write_source_file_map_2(Stream), FileNames, !IO),
> + list.foldl2(write_source_file_map_2(Stream), FileNames, set.init, _,
> + !IO),
> io.close_output(Stream, !IO)
> ;
> OpenRes = error(Error),
> @@ -189,12 +191,22 @@
> ).
>
> :- pred write_source_file_map_2(io.output_stream::in, file_name::in,
> - io::di, io::uo) is det.
> + set(module_name)::in, set(module_name)::out, io::di, io::uo) is det.
>
> -write_source_file_map_2(MapStream, FileName, !IO) :-
> +write_source_file_map_2(MapStream, FileName, SeenModules0, SeenModules, !IO) :-
> find_module_name(FileName, MaybeModuleName, !IO),
> (
> MaybeModuleName = yes(ModuleName),
> + ( set.contains(SeenModules0, ModuleName) ->
> + io.write_string("mercury_compile: module `", !IO),
> + io.write_string(sym_name_to_string(ModuleName), !IO),
> + io.write_string("' defined in multiple files.", !IO),
That's fine although it would also be useful to know what files
define the same module.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list