[m-rev.] for review: representation of ":- module" and ":- end_module"

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Nov 4 17:07:37 AEDT 2009


I am seeking feedback mostly on the user-visible change in behavior in
the absence of :- module declarations at the starts of source files,
though comments on the code are also welcome. I will fix the ZZZs before
commit.

Zoltan.

Represent ":- module" and ":- end_module" items using purpose-specific kinds of
items, instead of as part of the generic "module_defn" item kind. This is in
preparation for a diff that would return submodules as separate entities in
their own right, instead of as an embedded sequence of items that happen
to start with a :- module item and end with an optional :- end_module item.

Also as preparation, make missing a ":- module" declaration at the start of a
source file an error instead of a warning.

compiler/prog_item.m:
	Change the type representing items.

compiler/prog_io.m:
	Conform to the change above, make missing module declarations into an
	error, and simplify some code.

compiler/equiv_type.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Conform to the change above. Where relevant, turn chains of
	if-then-elses on item types into switches.

compiler/inst.m:
	Make the module name in the module declaration match the module name.

tests/invalid/big_test.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/typeclass_test_1.err_exp:
	Update the expected error messages.

tests/valid/inhibit_warn_test.m:
	To keep this test case valid, don't omit the ":- module" declaration.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.83
diff -u -b -r1.83 equiv_type.m
--- compiler/equiv_type.m	2 Jan 2009 03:12:06 -0000	1.83
+++ compiler/equiv_type.m	2 Nov 2009 06:51:58 -0000
@@ -208,20 +208,42 @@
 skip_abstract_imported_items([], []).
 skip_abstract_imported_items([Item0 | Items0], Items) :-
     (
+        ( Item0 = item_module_start(_)
+        ; Item0 = item_module_end(_)
+        ),
+        Items = Items0
+    ;
         Item0 = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
+        ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
+        (
         is_section_defn(ModuleDefn) = yes,
         ModuleDefn \= md_abstract_imported
     ->
         Items = Items0
     ;
         skip_abstract_imported_items(Items0, Items)
+        )
+    ;
+        ( Item0 = item_clause(_)
+        ; Item0 = item_type_defn(_)
+        ; Item0 = item_inst_defn(_)
+        ; Item0 = item_mode_defn(_)
+        ; Item0 = item_pred_decl(_)
+        ; Item0 = item_mode_decl(_)
+        ; Item0 = item_pragma(_)
+        ; Item0 = item_promise(_)
+        ; Item0 = item_typeclass(_)
+        ; Item0 = item_instance(_)
+        ; Item0 = item_initialise(_)
+        ; Item0 = item_finalise(_)
+        ; Item0 = item_mutable(_)
+        ; Item0 = item_nothing(_)
+        ),
+        skip_abstract_imported_items(Items0, Items)
     ).
 
 :- func is_section_defn(module_defn) = bool.
 
-is_section_defn(md_module(_)) = yes.
-is_section_defn(md_end_module(_)) = yes.
 is_section_defn(md_interface) = yes.
 is_section_defn(md_implementation) = yes.
 is_section_defn(md_private_interface) = yes.
@@ -253,7 +275,8 @@
         !Specs).
 replace_in_item_list(ModuleName, Location0, [Item0 | Items0],
         EqvMap, EqvInstMap, !ReplItems, !RecompInfo, !UsedModules, !Specs) :-
-    ( Item0 = item_module_defn(ItemModuleDefn) ->
+    (
+        Item0 = item_module_defn(ItemModuleDefn),
         ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
         (
             ModuleDefn = md_interface,
@@ -270,23 +293,41 @@
             ; ModuleDefn = md_abstract_imported
             ; ModuleDefn = md_opt_imported
             ; ModuleDefn = md_transitively_imported
-            % XXX I'm not sure what these two are so they may not signify
+            % XXX I'm not sure what this is so it may not signify
             % that we've finished processing the module.
-            ; ModuleDefn = md_external(_, _)
             ; ModuleDefn = md_export(_)
             ),
             Location = eqv_type_out_of_module
         ;
-            ( ModuleDefn = md_module(_)
-            ; ModuleDefn = md_end_module(_)
-            ; ModuleDefn = md_import(_)
+            ( ModuleDefn = md_import(_)
             ; ModuleDefn = md_use(_)
             ; ModuleDefn = md_include_module(_)
+            ; ModuleDefn = md_external(_, _)
             ; ModuleDefn = md_version_numbers(_, _)
             ),
             Location = Location0
         )
     ;
+        ( Item0 = item_module_start(_)
+        ; Item0 = item_module_end(_)
+        ),
+        unexpected(this_file, "replace_in_item_list: module start or end")
+    ;
+        ( Item0 = item_clause(_)
+        ; Item0 = item_type_defn(_)
+        ; Item0 = item_inst_defn(_)
+        ; Item0 = item_mode_defn(_)
+        ; Item0 = item_pred_decl(_)
+        ; Item0 = item_mode_decl(_)
+        ; Item0 = item_pragma(_)
+        ; Item0 = item_promise(_)
+        ; Item0 = item_typeclass(_)
+        ; Item0 = item_instance(_)
+        ; Item0 = item_initialise(_)
+        ; Item0 = item_finalise(_)
+        ; Item0 = item_mutable(_)
+        ; Item0 = item_nothing(_)
+        ),
         Location = Location0
     ),
     replace_in_item(ModuleName, Location, EqvMap, EqvInstMap,
@@ -351,7 +392,9 @@
         Item = Item0,
         Specs = []
     ;
-        ( Item0 = item_module_defn(_)
+        ( Item0 = item_module_start(_)
+        ; Item0 = item_module_end(_)
+        ; Item0 = item_module_defn(_)
         ; Item0 = item_clause(_)
         ; Item0 = item_inst_defn(_)
         ; Item0 = item_promise(_)
Index: compiler/inst.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/inst.m,v
retrieving revision 1.13
diff -u -b -r1.13 inst.m
--- compiler/inst.m	24 Oct 2005 04:14:06 -0000	1.13
+++ compiler/inst.m	31 Oct 2009 14:37:37 -0000
@@ -6,4 +6,4 @@
 %
 % The former contents of this file are now prog_data.m.
 
-:- module mer_inst.
+:- module (inst).
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.95
diff -u -b -r1.95 make_hlds_passes.m
--- compiler/make_hlds_passes.m	4 Nov 2009 03:44:48 -0000	1.95
+++ compiler/make_hlds_passes.m	4 Nov 2009 03:45:54 -0000
@@ -309,6 +309,12 @@
 
 add_item_decl_pass_1(Item, FoundError, !Status, !ModuleInfo, !Specs) :-
     (
+        Item = item_module_start(_),
+        FoundError = no
+    ;
+        Item = item_module_end(_),
+        FoundError = no
+    ;
         Item = item_module_defn(ItemModuleDefn),
         add_pass_1_module_defn(ItemModuleDefn, !Status, !ModuleInfo, !Specs),
         FoundError = no
@@ -449,15 +455,15 @@
     ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _SeqNum),
     ( module_defn_update_import_status(ModuleDefn, StatusPrime) ->
         !:Status = StatusPrime
-    ; ModuleDefn = md_import(ModuleSpecifiers) ->
-        !.Status = item_status(IStat, _),
-        add_module_specifiers(ModuleSpecifiers, IStat, !ModuleInfo)
-    ; ModuleDefn = md_use(ModuleSpecifiers) ->
+    ;
+        (
+            ( ModuleDefn = md_import(ModuleSpecifiers)
+            ; ModuleDefn = md_use(ModuleSpecifiers)
+            ),
         !.Status = item_status(IStat, _),
         add_module_specifiers(ModuleSpecifiers, IStat, !ModuleInfo)
-    ; ModuleDefn = md_include_module(_) ->
-        true
-    ; ModuleDefn = md_external(MaybeBackend, External) ->
+        ;
+            ModuleDefn = md_external(MaybeBackend, External),
         ( External = name_arity(Name, Arity) ->
             module_info_get_globals(!.ModuleInfo, Globals),
             CurrentBackend = lookup_current_backend(Globals),
@@ -478,22 +484,35 @@
             Pieces = [words("Warning:"), quote("external"),
                 words("declaration requires arity."), nl],
             Msg = simple_msg(Context, [always(Pieces)]),
-            Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
+                Spec = error_spec(severity_error, phase_parse_tree_to_hlds,
+                    [Msg]),
             !:Specs = [Spec | !.Specs]
         )
-    ; ModuleDefn = md_module(_ModuleName) ->
-        report_unexpected_decl("module", Context, !Specs)
-    ; ModuleDefn = md_end_module(_ModuleName) ->
-        report_unexpected_decl("end_module", Context, !Specs)
-    ; ModuleDefn = md_version_numbers(_, _) ->
-        true
-    ; ModuleDefn = md_transitively_imported ->
-        true
     ;
+            ( ModuleDefn = md_include_module(_)
+            ; ModuleDefn = md_version_numbers(_, _)
+            ; ModuleDefn = md_transitively_imported
+            )
+        ;
+            ( ModuleDefn = md_interface
+            ; ModuleDefn = md_implementation
+            ; ModuleDefn = md_private_interface
+            ; ModuleDefn = md_imported(_)
+            ; ModuleDefn = md_used(_)
+            ; ModuleDefn = md_opt_imported
+            ; ModuleDefn = md_abstract_imported
+            ),
+            unexpected(this_file,
+                "add_pass_1_module_defn: " ++
+                "module_defn_update_import_status missed something")
+        ;
+            ModuleDefn = md_export(_),
         Pieces = [words("Warning: declaration not yet implemented."), nl],
         Msg = simple_msg(Context, [always(Pieces)]),
-        Spec = error_spec(severity_warning, phase_parse_tree_to_hlds, [Msg]),
+            Spec = error_spec(severity_warning, phase_parse_tree_to_hlds,
+                [Msg]),
         !:Specs = [Spec | !.Specs]
+        )
     ).
 
 :- pred add_pass_1_mutable(item_mutable_info::in,
@@ -700,7 +719,9 @@
         Item = item_mutable(ItemMutable),
         add_pass_2_mutable(ItemMutable, !.Status, !ModuleInfo, !Specs)
     ;
-        ( Item = item_clause(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_clause(_)
         ; Item = item_inst_defn(_)
         ; Item = item_mode_defn(_)
         ; Item = item_mode_decl(_)
@@ -1040,7 +1061,9 @@
         add_pass_3_mutable(ItemMutable, !.Status, !ModuleInfo, !QualInfo,
             !Specs)
     ;
-        ( Item = item_inst_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_inst_defn(_)
         ; Item = item_mode_defn(_)
         ; Item = item_mode_decl(_)
         ; Item = item_typeclass(_)
@@ -2775,20 +2798,29 @@
 :- pred module_defn_update_import_status(module_defn::in, item_status::out)
     is semidet.
 
-module_defn_update_import_status(md_interface,
-        item_status(status_exported, may_be_unqualified)).
-module_defn_update_import_status(md_implementation,
-        item_status(status_local, may_be_unqualified)).
-module_defn_update_import_status(md_private_interface,
-        item_status(status_exported_to_submodules, may_be_unqualified)).
-module_defn_update_import_status(md_imported(Section),
-        item_status(status_imported(Section), may_be_unqualified)).
-module_defn_update_import_status(md_used(Section),
-        item_status(status_imported(Section), must_be_qualified)).
-module_defn_update_import_status(md_opt_imported,
-        item_status(status_opt_imported, must_be_qualified)).
-module_defn_update_import_status(md_abstract_imported,
-        item_status(status_abstract_imported, must_be_qualified)).
+module_defn_update_import_status(ModuleDefn, Status) :-
+    (
+        ModuleDefn = md_interface,
+        Status = item_status(status_exported, may_be_unqualified)
+    ;
+        ModuleDefn = md_implementation,
+        Status = item_status(status_local, may_be_unqualified)
+    ;
+        ModuleDefn = md_private_interface,
+        Status = item_status(status_exported_to_submodules, may_be_unqualified)
+    ;
+        ModuleDefn = md_imported(Section),
+        Status = item_status(status_imported(Section), may_be_unqualified)
+    ;
+        ModuleDefn = md_used(Section),
+        Status = item_status(status_imported(Section), must_be_qualified)
+    ;
+        ModuleDefn = md_opt_imported,
+        Status = item_status(status_opt_imported, must_be_qualified)
+    ;
+        ModuleDefn = md_abstract_imported,
+        Status = item_status(status_abstract_imported, must_be_qualified)
+    ).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.339
diff -u -b -r1.339 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	4 Nov 2009 03:44:48 -0000	1.339
+++ compiler/mercury_to_mercury.m	4 Nov 2009 03:45:55 -0000
@@ -494,6 +494,18 @@
 
 mercury_output_item(Info, Item, !IO) :-
     (
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart = item_module_start_info(ModuleName, _, _),
+        io.write_string(":- module ", !IO),
+        mercury_output_bracketed_sym_name(ModuleName, !IO),
+        io.write_string(".\n", !IO)
+    ;
+        Item = item_module_end(ItemModuleEnd),
+        ItemModuleEnd = item_module_end_info(ModuleName, _, _),
+        io.write_string(":- end_module ", !IO),
+        mercury_output_bracketed_sym_name(ModuleName, !IO),
+        io.write_string(".\n", !IO)
+    ;
         Item = item_module_defn(ItemModuleDefn),
         mercury_output_item_module_defn(Info, ItemModuleDefn, !IO)
     ;
@@ -567,8 +579,8 @@
     maybe_output_line_number(Info, Context, !IO),
     mercury_output_inst_defn(VarSet, Name, Args, InstDefn, Context, !IO).
 
-:- pred mercury_output_item_mode_defn(merc_out_info::in, item_mode_defn_info::in,
-    io::di, io::uo) is det.
+:- pred mercury_output_item_mode_defn(merc_out_info::in,
+    item_mode_defn_info::in, io::di, io::uo) is det.
 
 mercury_output_item_mode_defn(Info, ItemModeDefn, !IO) :-
     ItemModeDefn = item_mode_defn_info(VarSet, Name0, Args, ModeDefn, _Cond,
@@ -577,8 +589,8 @@
     maybe_output_line_number(Info, Context, !IO),
     mercury_format_mode_defn(VarSet, Name, Args, ModeDefn, Context, !IO).
 
-:- pred mercury_output_item_pred_decl(merc_out_info::in, item_pred_decl_info::in,
-    io::di, io::uo) is det.
+:- pred mercury_output_item_pred_decl(merc_out_info::in,
+    item_pred_decl_info::in, io::di, io::uo) is det.
 
 mercury_output_item_pred_decl(Info, ItemPredDecl, !IO) :-
     ItemPredDecl = item_pred_decl_info(_Origin, TypeVarSet, InstVarSet,
@@ -604,8 +616,8 @@
             Purity, ClassContext, Context, ":- ", ".\n", ".\n", !IO)
     ).
 
-:- pred mercury_output_item_mode_decl(merc_out_info::in, item_mode_decl_info::in,
-    io::di, io::uo) is det.
+:- pred mercury_output_item_mode_decl(merc_out_info::in,
+    item_mode_decl_info::in, io::di, io::uo) is det.
 
 mercury_output_item_mode_decl(Info, ItemModeDecl, !IO) :-
     ItemModeDecl = item_mode_decl_info(VarSet, PredOrFunc, PredName0, Modes,
@@ -907,8 +919,8 @@
     mercury_output_goal(Goal, VarSet, Indent, !IO),
     io.write_string(".\n", !IO).
 
-:- pred mercury_output_item_typeclass(merc_out_info::in, item_typeclass_info::in,
-    io::di, io::uo) is det.
+:- pred mercury_output_item_typeclass(merc_out_info::in,
+    item_typeclass_info::in, io::di, io::uo) is det.
 
 mercury_output_item_typeclass(Info, ItemTypeClass, !IO) :-
     ItemTypeClass = item_typeclass_info(Constraints, FunDeps, ClassName0,
@@ -967,8 +979,8 @@
     ),
     io.write_string(".\n", !IO).
 
-:- pred mercury_output_item_initialise(merc_out_info::in, item_initialise_info::in,
-    io::di, io::uo) is det.
+:- pred mercury_output_item_initialise(merc_out_info::in,
+    item_initialise_info::in, io::di, io::uo) is det.
 
 mercury_output_item_initialise(_, ItemInitialise, !IO) :-
     ItemInitialise = item_initialise_info(_, PredSymName, Arity, _Context,
@@ -1147,21 +1159,11 @@
         mercury_write_module_spec_list(IncludedModules, !IO),
         io.write_string(".\n", !IO)
     ;
-        ModuleDefn = md_module(Module),
-        io.write_string(":- module ", !IO),
-        mercury_output_bracketed_sym_name(Module, !IO),
-        io.write_string(".\n", !IO)
-    ;
-        ModuleDefn = md_end_module(Module),
-        io.write_string(":- end_module ", !IO),
-        mercury_output_bracketed_sym_name(Module, !IO),
-        io.write_string(".\n", !IO)
-    ;
-        ModuleDefn = md_version_numbers(Module, VersionNumbers),
+        ModuleDefn = md_version_numbers(ModuleName, VersionNumbers),
         io.write_string(":- version_numbers(", !IO),
         io.write_int(version_numbers_version_number, !IO),
         io.write_string(", ", !IO),
-        mercury_output_bracketed_sym_name(Module, !IO),
+        mercury_output_bracketed_sym_name(ModuleName, !IO),
         io.write_string(",\n", !IO),
         recompilation.version.write_version_numbers(VersionNumbers, !IO),
         io.write_string(").\n", !IO)
@@ -1786,15 +1788,15 @@
         % add_lambda_eval_method(EvalMethod, !U),
         add_string(")>", !U)
     ;
-        ConsId = type_ctor_info_const(Module, Type, Arity),
-        ModuleString = sym_name_to_string(Module),
+        ConsId = type_ctor_info_const(ModuleName, Type, Arity),
+        ModuleString = sym_name_to_string(ModuleName),
         string.int_to_string(Arity, ArityString),
         add_strings(["<type_ctor_info for ",
             ModuleString, ".", Type, "/", ArityString, ">"], !U)
     ;
-        ConsId = base_typeclass_info_const(Module, Class, InstanceNum,
+        ConsId = base_typeclass_info_const(ModuleName, Class, InstanceNum,
             InstanceString),
-        ModuleString = sym_name_to_string(Module),
+        ModuleString = sym_name_to_string(ModuleName),
         add_string("<base_typeclass_info for ", !U),
         add_class_id(Class, !U),
         ( ModuleString \= "some bogus module name" ->
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.175
diff -u -b -r1.175 module_qual.m
--- compiler/module_qual.m	8 Sep 2009 02:43:35 -0000	1.175
+++ compiler/module_qual.m	31 Oct 2009 13:52:42 -0000
@@ -278,6 +278,16 @@
 
 collect_mq_info_item(Item, !Info) :-
     (
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart = item_module_start_info(ModuleName, _, _),
+        add_module_defn(ModuleName, !Info)
+    ;
+        Item = item_module_end(_)
+    ;
+        Item = item_module_defn(ItemModuleDefn),
+        ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
+        process_module_defn(ModuleDefn, !Info)
+    ;
         Item = item_type_defn(ItemTypeDefn),
         ItemTypeDefn = item_type_defn_info(_, SymName, Params, _, _, _, _),
         ( mq_info_get_import_status(!.Info, mq_status_abstract_imported) ->
@@ -321,10 +331,6 @@
             mq_info_set_modes(Modes, !Info)
         )
     ;
-        Item = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
-        process_module_defn(ModuleDefn, !Info)
-    ;
         Item = item_promise(ItemPromise),
         ItemPromise = item_promise_info(_PromiseType, Goal, _ProgVarSet,
             _UnivVars, _Context, _SeqNum),
@@ -395,8 +401,6 @@
     %
 :- pred process_module_defn(module_defn::in, mq_info::in, mq_info::out) is det.
 
-process_module_defn(md_module(ModuleName), !Info) :-
-    add_module_defn(ModuleName, !Info).
 process_module_defn(md_include_module(ModuleNameList), !Info) :-
     list.foldl(add_module_defn, ModuleNameList, !Info).
 process_module_defn(md_interface, !Info) :-
@@ -421,7 +425,6 @@
 process_module_defn(md_transitively_imported, !Info) :-
     unexpected(this_file, "process_module_defn: transitively_imported item").
 process_module_defn(md_external(_, _), !Info).
-process_module_defn(md_end_module(_), !Info).
 process_module_defn(md_export(_), !Info).
 process_module_defn(md_import(Imports), !Info) :-
     add_imports(Imports, !Info).
@@ -723,10 +726,22 @@
 
 module_qualify_item(Item0, Item, Continue, !Info, !Specs) :-
     (
-        Item0 = item_clause(_),
+        ( Item0 = item_module_start(_)
+        ; Item0 = item_module_end(_)
+        ; Item0 = item_clause(_)
+        ; Item0 = item_initialise(_)
+        ; Item0 = item_finalise(_)
+        ; Item0 = item_promise(_)
+        ; Item0 = item_nothing(_)
+        ),
         Item = Item0,
         Continue = yes
     ;
+        Item0 = item_module_defn(ItemModuleDefn),
+        ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
+        update_import_status(ModuleDefn, !Info, Continue),
+        Item = Item0
+    ;
         Item0 = item_type_defn(ItemTypeDefn0),
         ItemTypeDefn0 = item_type_defn_info(TVarSet, SymName, Params,
             TypeDefn0, C, Context, SeqNum),
@@ -763,12 +778,6 @@
         Item = item_mode_defn(ItemModeDefn),
         Continue = yes
     ;
-        Item0 = item_module_defn(ItemModuleDefn0),
-        ItemModuleDefn0 = item_module_defn_info(ModuleDefn, Context, SeqNum),
-        update_import_status(ModuleDefn, !Info, Continue),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
-        Item = item_module_defn(ItemModuleDefn)
-    ;
         Item0 = item_pred_decl(ItemPredDecl0),
         ItemPredDecl0 = item_pred_decl_info(Origin, A, IVs, B, PredOrFunc,
             SymName, TypesAndModes0, WithType0, WithInst0, C, D, E,
@@ -810,14 +819,6 @@
         Item = item_pragma(ItemPragma),
         Continue = yes
     ;
-        Item0 = item_promise(_),
-        Item = Item0,
-        Continue = yes
-    ;
-        Item0 = item_nothing(_),
-        Item = Item0,
-        Continue = yes
-    ;
         Item0 = item_typeclass(ItemTypeClass0),
         ItemTypeClass0 = item_typeclass_info(Constraints0, FunDeps,
             Name, Vars, Interface0, VarSet, Context, SeqNum),
@@ -856,14 +857,6 @@
         Item = item_instance(ItemInstance),
         Continue = yes
     ;
-        Item0 = item_initialise(_),
-        Item = Item0,
-        Continue = yes
-    ;
-        Item0 = item_finalise(_O),
-        Item = Item0,
-        Continue = yes
-    ;
         Item0 = item_mutable(ItemMutable0),
         ItemMutable0 = item_mutable_info(Name, Type0, InitTerm, Inst0,
             Attrs, Varset, Context, SeqNum),
@@ -925,7 +918,6 @@
 update_import_status(md_abstract_imported, !Info, yes) :-
     mq_info_set_import_status(mq_status_abstract_imported, !Info).
 update_import_status(md_transitively_imported, !Info, no).
-update_import_status(md_module(_), !Info, yes).
 update_import_status(md_interface, !Info, yes) :-
     mq_info_set_import_status(mq_status_exported, !Info).
 update_import_status(md_implementation, !Info, yes) :-
@@ -935,7 +927,6 @@
 update_import_status(md_imported(_), !Info, no).
 update_import_status(md_used(_), !Info, no).
 update_import_status(md_external(_, _), !Info, yes).
-update_import_status(md_end_module(_), !Info, yes).
 update_import_status(md_export(_), !Info, yes).
 update_import_status(md_import(_), !Info, yes).
 update_import_status(md_use(_), !Info, yes).
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.456
diff -u -b -r1.456 modules.m
--- compiler/modules.m	14 Oct 2009 05:28:40 -0000	1.456
+++ compiler/modules.m	2 Nov 2009 06:49:18 -0000
@@ -650,7 +650,8 @@
 
 strip_imported_items_2([], !RevItems).
 strip_imported_items_2([Item | Items], !RevItems) :-
-    ( Item = item_module_defn(ItemModuleDefn) ->
+    (
+        Item = item_module_defn(ItemModuleDefn),
         ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
         (
             ( ModuleDefn = md_imported(_)
@@ -661,9 +662,7 @@
             % Item and everything in Items from the list.
         ;
             % XXX Some of these should probably cause an error message.
-            ( ModuleDefn = md_module(_)
-            ; ModuleDefn = md_end_module(_)
-            ; ModuleDefn = md_interface
+            ( ModuleDefn = md_interface
             ; ModuleDefn = md_implementation
             ; ModuleDefn = md_private_interface
             ; ModuleDefn = md_opt_imported
@@ -679,6 +678,23 @@
             strip_imported_items_2(Items, !RevItems)
         )
     ;
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_clause(_)
+        ; Item = item_type_defn(_)
+        ; Item = item_inst_defn(_)
+        ; Item = item_mode_defn(_)
+        ; Item = item_pred_decl(_)
+        ; Item = item_mode_decl(_)
+        ; Item = item_pragma(_)
+        ; Item = item_promise(_)
+        ; Item = item_typeclass(_)
+        ; Item = item_instance(_)
+        ; Item = item_initialise(_)
+        ; Item = item_finalise(_)
+        ; Item = item_mutable(_)
+        ; Item = item_nothing(_)
+        ),
         !:RevItems = [Item | !.RevItems],
         strip_imported_items_2(Items, !RevItems)
     ).
@@ -859,9 +875,7 @@
                     "do_standardize_impl_items: non-singleton-module use")
             )
         ;
-            ( ModuleDefn = md_module(_)
-            ; ModuleDefn = md_end_module(_)
-            ; ModuleDefn = md_imported(_)
+            ( ModuleDefn = md_imported(_)
             ; ModuleDefn = md_used(_)
             ; ModuleDefn = md_abstract_imported
             ; ModuleDefn = md_opt_imported
@@ -1314,7 +1328,9 @@
         list.foldl(get_requirements_of_impl_from_constraint, Constraints,
             !Modules)
     ;
-        ( Item = item_module_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
         ; Item = item_clause(_)
         ; Item = item_type_defn(_)
         ; Item = item_inst_defn(_)
@@ -1445,7 +1461,9 @@
             Items = [Item0 | Items1]
         )
     ;
-        ( Item0 = item_module_defn(_)
+        ( Item0 = item_module_start(_)
+        ; Item0 = item_module_end(_)
+        ; Item0 = item_module_defn(_)
         ; Item0 = item_type_defn(_)
         ; Item0 = item_inst_defn(_)
         ; Item0 = item_mode_defn(_)
@@ -3132,7 +3150,8 @@
 
 get_accessible_children_2(_, [], !IncludeDeps).
 get_accessible_children_2(!.Visible, [Item | Items], !IncludeDeps) :-
-    ( Item = item_module_defn(ItemModuleDefn) ->
+    (
+        Item = item_module_defn(ItemModuleDefn),
         ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
         (
             ( ModuleDefn = md_abstract_imported
@@ -3157,9 +3176,7 @@
                 !.Visible = no
             )
         ;
-            ( ModuleDefn = md_module(_)
-            ; ModuleDefn = md_end_module(_)
-            ; ModuleDefn = md_external(_, _)
+            ( ModuleDefn = md_external(_, _)
             ; ModuleDefn = md_export(_)
             ; ModuleDefn = md_import(_)
             ; ModuleDefn = md_use(_)
@@ -3168,7 +3185,23 @@
             % Do nothing.
         )
     ;
-        true
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_clause(_)
+        ; Item = item_type_defn(_)
+        ; Item = item_inst_defn(_)
+        ; Item = item_mode_defn(_)
+        ; Item = item_pred_decl(_)
+        ; Item = item_mode_decl(_)
+        ; Item = item_pragma(_)
+        ; Item = item_promise(_)
+        ; Item = item_typeclass(_)
+        ; Item = item_instance(_)
+        ; Item = item_initialise(_)
+        ; Item = item_finalise(_)
+        ; Item = item_mutable(_)
+        ; Item = item_nothing(_)
+        )
     ),
     get_accessible_children_2(!.Visible, Items, !IncludeDeps).
 
@@ -3231,9 +3264,9 @@
     (
         % Check for a `module' declaration, which signals the start
         % of a nested module.
-        Item = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
-        ModuleDefn = md_module(SubModuleName)
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart =
+            item_module_start_info(SubModuleName, Context, SeqNum)
     ->
         % Parse in the items for the nested submodule.
         split_into_submodules_2(SubModuleName, Items1, !.InInterface,
@@ -3256,9 +3289,8 @@
         OtherItems = Items3
     ;
         % Check for a matching `end_module' declaration.
-        Item = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, _Context, _),
-        ModuleDefn = md_end_module(EndModuleName),
+        Item = item_module_end(ItemModuleEnd),
+        ItemModuleEnd = item_module_end_info(EndModuleName, _, _),
         EndModuleName = ModuleName
     ->
         % If so, that's the end of this module.
@@ -3357,24 +3389,37 @@
     list(error_spec)::in, list(error_spec)::out) is det.
 
 report_duplicate_modules(Duplicates, Items, !Specs) :-
-    solutions.solutions(is_duplicate_error(Duplicates, Items),
-        DuplicateErrors),
+    list.filter_map(is_duplicate_error(Duplicates), Items,
+        DuplicateErrorLists),
+    list.condense(DuplicateErrorLists, DuplicateErrors),
     list.foldl(report_error_duplicate_module_decl, DuplicateErrors, !Specs).
 
-:- pred is_duplicate_error(set(module_name)::in, list(item)::in,
-    pair(module_name, prog_context)::out) is nondet.
+:- pred is_duplicate_error(set(module_name)::in, item::in,
+    list(pair(module_name, prog_context))::out) is semidet.
 
-is_duplicate_error(Duplicates, Items, SubModuleName - Context) :-
-    list.member(Item, Items),
-    Item = item_module_defn(ItemModuleDefn),
-    ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _),
+is_duplicate_error(DuplicatesSet, Item, SubModuleNameContexts) :-
     (
-        ModuleDefn = md_module(SubModuleName)
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart = item_module_start_info(SubModuleName, Context, _),
+        set.member(SubModuleName, DuplicatesSet),
+        SubModuleNameContexts = [SubModuleName - Context]
     ;
+        Item = item_module_defn(ItemModuleDefn),
+        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _),
         ModuleDefn = md_include_module(SubModuleNames),
-        list.member(SubModuleName, SubModuleNames)
-    ),
-    set.member(SubModuleName, Duplicates).
+        set.list_to_set(SubModuleNames, SubModuleNamesSet),
+        set.intersect(SubModuleNamesSet, DuplicatesSet,
+            DuplicatedSubModuleNamesSet),
+        set.to_sorted_list(DuplicatedSubModuleNamesSet,
+            DuplicatedSubModuleNames),
+        SubModuleNameContexts =
+            list.map(pair_with_context(Context), DuplicatedSubModuleNames)
+    ).
+
+:- func pair_with_context(prog_context, module_name) =
+    pair(module_name, prog_context).
+
+pair_with_context(Context, ModuleName) = ModuleName - Context.
 
 :- pred report_error_duplicate_module_decl(pair(module_name, prog_context)::in,
     list(error_spec)::in, list(error_spec)::out) is det.
@@ -3601,7 +3646,9 @@
 
 include_in_short_interface(Item) = Include :-
     (
-        ( Item = item_module_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
         ; Item = item_type_defn(_)
         ; Item = item_inst_defn(_)
         ; Item = item_mode_defn(_)
@@ -3661,7 +3708,9 @@
         ),
         NeedsImports = yes
     ;
-        ( Item = item_module_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
         ; Item = item_nothing(_)
         ),
         NeedsImports = no
@@ -3732,7 +3781,9 @@
             Langs = []
         )
     ;
-        ( Item = item_module_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
         ; Item = item_clause(_)
         ; Item = item_inst_defn(_)
         ; Item = item_mode_defn(_)
@@ -3764,9 +3815,7 @@
         ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
         (
             % XXX Some of these should yield an exception.
-            ( ModuleDefn = md_module(_)
-            ; ModuleDefn = md_end_module(_)
-            ; ModuleDefn = md_interface
+            ( ModuleDefn = md_interface
             ; ModuleDefn = md_implementation
             ; ModuleDefn = md_private_interface
             ; ModuleDefn = md_imported(_)
@@ -3830,7 +3879,9 @@
             Include = no
         )
     ;
-        ( Item = item_clause(_)
+        ( Item = item_module_start(_)   % ZZZ was yes
+        ; Item = item_module_end(_)     % ZZZ was yes
+        ; Item = item_clause(_)
         ; Item = item_inst_defn(_)
         ; Item = item_mode_defn(_)
         ; Item = item_pred_decl(_)
@@ -4157,7 +4208,9 @@
         ),
         Reorderable = yes
     ;
-        ( Item = item_clause(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_clause(_)
         ; Item = item_pred_decl(_)
         ; Item = item_mode_decl(_)
         ; Item = item_initialise(_)
@@ -4173,14 +4226,12 @@
 reorderable_module_defn(ModuleDefn) = Reorderable :-
     ( ModuleDefn = md_import(_), Reorderable = yes
     ; ModuleDefn = md_abstract_imported, Reorderable = no
-    ; ModuleDefn = md_end_module(_), Reorderable = no
     ; ModuleDefn = md_export(_), Reorderable = yes
     ; ModuleDefn = md_external(_, _), Reorderable = yes
     ; ModuleDefn = md_implementation, Reorderable = no
     ; ModuleDefn = md_imported(_), Reorderable = no
     ; ModuleDefn = md_include_module(_), Reorderable = no
     ; ModuleDefn = md_interface, Reorderable = no
-    ; ModuleDefn = md_module(_), Reorderable = no
     ; ModuleDefn = md_opt_imported, Reorderable = no
     ; ModuleDefn = md_private_interface, Reorderable = no
     ; ModuleDefn = md_transitively_imported, Reorderable = no
@@ -4266,7 +4317,10 @@
         ),
         Chunkable = yes
     ;
-        Item = item_mutable(_),
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_mutable(_)
+        ),
         Chunkable = no
     ).
 
@@ -4274,7 +4328,6 @@
 
 chunkable_module_defn(ModuleDefn) = Reorderable :-
     ( ModuleDefn = md_abstract_imported, Reorderable = no
-    ; ModuleDefn = md_end_module(_), Reorderable = no
     ; ModuleDefn = md_export(_), Reorderable = yes
     ; ModuleDefn = md_external(_, _), Reorderable = yes
     ; ModuleDefn = md_implementation, Reorderable = no
@@ -4282,7 +4335,6 @@
     ; ModuleDefn = md_imported(_), Reorderable = no
     ; ModuleDefn = md_include_module(_), Reorderable = no
     ; ModuleDefn = md_interface, Reorderable = no
-    ; ModuleDefn = md_module(_), Reorderable = no
     ; ModuleDefn = md_opt_imported, Reorderable = no
     ; ModuleDefn = md_private_interface, Reorderable = no
     ; ModuleDefn = md_transitively_imported, Reorderable = no
Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.301
diff -u -b -r1.301 prog_io.m
--- compiler/prog_io.m	14 Oct 2009 05:28:42 -0000	1.301
+++ compiler/prog_io.m	2 Nov 2009 06:50:10 -0000
@@ -222,21 +222,22 @@
 actually_read_module(Globals, OpenFile, DefaultModuleName, ReturnTimestamp,
         FileData, ModuleName, Items, Specs, Error, MaybeModuleTimestamp,
         !IO) :-
-    actually_read_module_2(Globals, OpenFile, DefaultModuleName,
+    do_actually_read_module(Globals, OpenFile, DefaultModuleName,
         no, ReturnTimestamp, FileData, ModuleName,
         Items, Specs, Error, MaybeModuleTimestamp, !IO).
 
 actually_read_module_if_changed(Globals, OpenFile, DefaultModuleName,
         OldTimestamp, FileData, ModuleName, Items, Specs, Error,
         MaybeModuleTimestamp, !IO) :-
-    actually_read_module_2(Globals, OpenFile, DefaultModuleName,
+    do_actually_read_module(Globals, OpenFile, DefaultModuleName,
         yes(OldTimestamp), do_return_timestamp, FileData, ModuleName,
         Items, Specs, Error,MaybeModuleTimestamp, !IO).
 
 actually_read_opt_file(Globals, FileName, DefaultModuleName,
         Items, Specs, Error, !IO) :-
     globals.lookup_accumulating_option(Globals, intermod_directories, Dirs),
-    actually_read_module_2(Globals, search_for_file(open_file, Dirs, FileName),
+    do_actually_read_module(Globals,
+        search_for_file(open_file, Dirs, FileName),
         DefaultModuleName, no, do_not_return_timestamp, _, ModuleName, Items,
         ItemSpecs, Error, _, !IO),
     check_module_has_expected_name(FileName, DefaultModuleName, ModuleName,
@@ -263,15 +264,15 @@
     % and then reverse them afterwards. (Using difference lists would require
     % late-input modes.)
     %
-:- pred actually_read_module_2(globals::in,
+:- pred do_actually_read_module(globals::in,
     open_file_pred(T)::in(open_file_pred), module_name::in,
     maybe(timestamp)::in, maybe_return_timestamp::in,
     maybe(T)::out, module_name::out, list(item)::out, list(error_spec)::out,
     module_error::out, maybe(io.res(timestamp))::out, io::di, io::uo) is det.
 
-actually_read_module_2(Globals, OpenFile, DefaultModuleName, MaybeOldTimestamp,
-        ReturnTimestamp, MaybeFileData, ModuleName, Items, Specs, Error,
-        MaybeModuleTimestamp, !IO) :-
+do_actually_read_module(Globals, OpenFile, DefaultModuleName,
+        MaybeOldTimestamp, ReturnTimestamp, MaybeFileData, ModuleName,
+        Items, Specs, Error, MaybeModuleTimestamp, !IO) :-
     io.input_stream(OldInputStream, !IO),
     OpenFile(OpenResult, !IO),
     (
@@ -464,9 +465,8 @@
         % nested module, the error will be caught by make_hlds.
 
         RevItems0 = [Item | RevItemsPrime],
-        Item = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _SeqNum),
-        ModuleDefn = md_end_module(ModuleName)
+        Item = item_module_end(ItemModuleEnd),
+        ItemModuleEnd = item_module_end_info(ModuleName, Context, _SeqNum)
     ->
         RevItems = RevItemsPrime,
         EndModule = module_end_yes(ModuleName, Context)
@@ -490,14 +490,14 @@
     % and remove it from the front of the item list.
     (
         !.Items = [Item | !:Items],
-        Item = item_module_defn(ItemModuleDefn),
-        ItemModuleDefn = item_module_defn_info(md_module(ModuleName1), _, _)
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart = item_module_start_info(StartModuleName, _, _)
     ->
         % Check that the end module declaration (if any) matches
         % the begin module declaration.
         (
             EndModule = module_end_yes(EndModuleName, EndModuleContext),
-            ModuleName1 \= EndModuleName
+            StartModuleName \= EndModuleName
         ->
             Pieces = [words("Error:"),
                 quote(":- end_module"), words("declaration"),
@@ -603,8 +603,9 @@
         io.input_stream(Stream, !IO),
         io.input_stream_name(Stream, SourceFileName0, !IO),
         read_first_item(DefaultModuleName, SourceFileName0, SourceFileName,
-            ModuleName, RevItems0, MaybeSecondTerm, !:Specs, !:Error,
+            ModuleName, ModuleDeclItem, MaybeSecondTerm, !:Specs, !:Error,
             !SeqNumCounter, !IO),
+        RevItems0 = [ModuleDeclItem],
         (
             MaybeSecondTerm = yes(SecondTerm),
             % XXX Should this be SourceFileName instead of SourceFileName0?
@@ -629,24 +630,24 @@
     ).
 
     % We need to jump through a few hoops when reading the first item,
-    % to allow the initial `:- module' declaration to be optional.
+    % to allow us to recover from a missing initial `:- module' declaration.
     % The reason is that in order to parse an item, we need to know
     % which module it is defined in (because we do some module
     % qualification and checking of module qualifiers at parse time),
     % but the initial `:- module' declaration and the declaration
     % that follows it occur in different scopes, so we need to know
-    % what it is that we're parsing before we can parse it!
+    % what it is that we are parsing before we can parse it!
     % We solve this dilemma by first parsing it in the root scope,
     % and then if it turns out to not be a `:- module' declaration
     % we reparse it in the default module scope. Blecchh.
     %
 :- pred read_first_item(module_name::in, file_name::in, file_name::out,
-    module_name::out, list(item)::out, maybe(read_term)::out,
+    module_name::out, item::out, maybe(read_term)::out,
     list(error_spec)::out, module_error::out, counter::in, counter::out,
     io::di, io::uo) is det.
 
 read_first_item(DefaultModuleName, !SourceFileName, ModuleName,
-        Items, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO) :-
+        ModuleDeclItem, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO) :-
     % Parse the first term, treating it as occurring within the scope
     % of the special "root" module (so that any `:- module' declaration
     % is taken to be a non-nested module unless explicitly qualified).
@@ -662,30 +663,31 @@
         Pragma = pragma_source_file(!:SourceFileName)
     ->
         read_first_item(DefaultModuleName, !SourceFileName, ModuleName,
-            Items, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO)
+            ModuleDeclItem, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO)
     ;
         % Check if the first term was a `:- module' decl.
         MaybeFirstItem = read_item_ok(FirstItem),
-        FirstItem = item_module_defn(FirstItemModuleDefn),
-        FirstItemModuleDefn = item_module_defn_info(ModuleDefn, FirstContext,
-            _FirstItemSeqNum),
-        ModuleDefn = md_module(StartModuleName)
+        FirstItem = item_module_start(FirstItemModuleStart),
+        FirstItemModuleStart = item_module_start_info(StartModuleName,
+            FirstContext, _FirstItemSeqNum)
     ->
         % If so, then check that it matches the expected module name,
         % and if not, report a warning.
         ( match_sym_name(StartModuleName, DefaultModuleName) ->
             ModuleName = DefaultModuleName,
-            Specs = []
+            Specs = [],
+            Error = no_module_errors
         ; match_sym_name(DefaultModuleName, StartModuleName) ->
             ModuleName = StartModuleName,
-            Specs = []
+            Specs = [],
+            Error = no_module_errors
         ;
             % XXX I think this should be an error, not a warning. -zs
-            Pieces = [words("Warning: source file"), quote(!.SourceFileName),
+            Pieces = [words("Error: source file"), quote(!.SourceFileName),
                 words("contains module named"), sym_name(StartModuleName),
                 suffix("."), nl],
             Severity = severity_conditional(warn_wrong_module_name, yes,
-                severity_warning, no),
+                severity_error, no),
             Msgs = [option_is_set(warn_wrong_module_name, yes,
                 [always(Pieces)])],
             Spec = error_spec(Severity, phase_term_to_parse_tree,
@@ -695,49 +697,42 @@
             % Which one should we use here? We used to use the default module
             % name (computed from the filename) but now we use the declared
             % one.
-            ModuleName = StartModuleName
+            ModuleName = StartModuleName,
+            Error = some_module_errors
         ),
-        make_module_decl(ModuleName, FirstContext, FixedFirstItem),
-        Items = [FixedFirstItem],
-        Error = no_module_errors,
+        make_module_decl(ModuleName, FirstContext, ModuleDeclItem),
         MaybeSecondTerm = no
     ;
-        % If the first term was not a `:- module' decl, then issue a warning
-        % (if warning enabled), and insert an implicit `:- module ModuleName'
-        % decl.
+        % If the first term was not a `:- module' decl, then generate an
+        % error message, and insert an implicit `:- module ModuleName' decl.
         ( MaybeFirstItem = read_item_ok(FirstItem) ->
             FirstContext = get_item_context(FirstItem)
         ;
             term.context_init(!.SourceFileName, 1, FirstContext)
         ),
-        % XXX I think this should be an error, not a warning. -zs
-        Pieces = [words("Warning: module should start with a"),
+        Pieces = [words("Error: module should start with a"),
             quote(":- module"), words("declaration."), nl],
-        Severity = severity_conditional(warn_missing_module_name, yes,
-            severity_warning, no),
-        Msgs  = [option_is_set(warn_missing_module_name, yes,
-            [always(Pieces)])],
+        Severity = severity_error,
+        Msgs  = [always(Pieces)],
         Spec = error_spec(Severity, phase_term_to_parse_tree,
             [simple_msg(FirstContext, Msgs)]),
         Specs = [Spec],
+        Error = some_module_errors,
 
         ModuleName = DefaultModuleName,
-        make_module_decl(ModuleName, FirstContext, FixedFirstItem),
+        make_module_decl(ModuleName, FirstContext, ModuleDeclItem),
 
         % Reparse the first term, this time treating it as occuring within
         % the scope of the implicit `:- module' decl rather than in the
         % root module.
-        MaybeSecondTerm = yes(MaybeFirstTerm),
-        Items = [FixedFirstItem],
-        Error = no_module_errors
+        MaybeSecondTerm = yes(MaybeFirstTerm)
     ).
 
 :- pred make_module_decl(module_name::in, term.context::in, item::out) is det.
 
 make_module_decl(ModuleName, Context, Item) :-
-    ModuleDefn = md_module(ModuleName),
-    ItemInfo = item_module_defn_info(ModuleDefn, Context, -1),
-    Item = item_module_defn(ItemInfo).
+    ItemInfo = item_module_start_info(ModuleName, Context, -1),
+    Item = item_module_start(ItemInfo).
 
 %-----------------------------------------------------------------------------%
 
@@ -794,43 +789,8 @@
     list(error_spec)::in, list(error_spec)::out,
     module_error::in, module_error::out, io::di, io::uo) is det.
 
-read_items_loop_ok(Globals, Item0, !ModuleName, !SourceFileName, !Items,
+read_items_loop_ok(Globals, Item, !ModuleName, !SourceFileName, !Items,
         !Specs, !Error, !IO) :-
-    (
-        Item0 = item_nothing(ItemNothing0),
-        ItemNothing0 = item_nothing_info(yes(Warning), Context0, NothingSeqNum)
-    ->
-        Warning = item_warning(MaybeOption, Msg, Term),
-        (
-            MaybeOption = yes(Option),
-            globals.lookup_bool_option(Globals, Option, Warn)
-        ;
-            MaybeOption = no,
-            Warn = yes
-        ),
-        (
-            Warn = yes,
-            Pieces = [words("Warning: "), words(Msg), nl],
-            Spec = error_spec(severity_error, phase_term_to_parse_tree,
-                [simple_msg(get_term_context(Term), [always(Pieces)])]),
-            !:Specs = [Spec | !.Specs],
-
-            globals.lookup_bool_option(Globals, halt_at_warn, Halt),
-            (
-                Halt = yes,
-                !:Error = some_module_errors
-            ;
-                Halt = no
-            )
-        ;
-            Warn = no
-        ),
-        ItemNothing = item_nothing_info(no, Context0, NothingSeqNum),
-        Item = item_nothing(ItemNothing)
-    ;
-        Item = Item0
-    ),
-
     % If the next item was a valid item, check whether it was a declaration
     % that affects the current parsing context -- i.e. either a `module' or
     % `end_module' declaration, or a `pragma source_file' declaration.
@@ -838,24 +798,21 @@
     % is a `pragma source_file' declaration, insert it into the item list.
     % Then continue looping.
     (
-        Item = item_pragma(ItemPragma),
-        ItemPragma = item_pragma_info(_, Pragma, _, _),
-        Pragma = pragma_source_file(NewSourceFileName)
-    ->
-        !:SourceFileName = NewSourceFileName
-    ;
-        Item = item_module_defn(ItemModuleDefn)
-    ->
-        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
-        ( ModuleDefn = md_module(NestedModuleName) ->
+        Item = item_module_start(ItemModuleStart),
+        ItemModuleStart = item_module_start_info(NestedModuleName, _, _),
             !:ModuleName = NestedModuleName,
             !:Items = [Item | !.Items]
-        ; ModuleDefn = md_end_module(NestedModuleName) ->
+    ;
+        Item = item_module_end(ItemModuleEnd),
+        ItemModuleEnd = item_module_end_info(NestedModuleName, _, _),
             sym_name_get_module_name_default(NestedModuleName,
                 root_module_name, ParentModuleName),
             !:ModuleName = ParentModuleName,
             !:Items = [Item | !.Items]
-        ; ModuleDefn = md_import(Modules) ->
+    ;
+        Item = item_module_defn(ItemModuleDefn),
+        ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
+        ( ModuleDefn = md_import(Modules) ->
             list.map(make_pseudo_import_module_decl(Context, SeqNum),
                 Modules, ImportItems),
             !:Items = ImportItems ++ !.Items
@@ -871,7 +828,65 @@
             !:Items = [Item | !.Items]
         )
     ;
+        Item = item_pragma(ItemPragma),
+        ItemPragma = item_pragma_info(_, Pragma, _, _),
+        ( Pragma = pragma_source_file(NewSourceFileName) ->
+            !:SourceFileName = NewSourceFileName
+        ;
+            !:Items = [Item | !.Items]
+        )
+    ;
+        ( Item = item_clause(_)
+        ; Item = item_type_defn(_)
+        ; Item = item_inst_defn(_)
+        ; Item = item_mode_defn(_)
+        ; Item = item_pred_decl(_)
+        ; Item = item_mode_decl(_)
+        ; Item = item_promise(_)
+        ; Item = item_typeclass(_)
+        ; Item = item_instance(_)
+        ; Item = item_initialise(_)
+        ; Item = item_finalise(_)
+        ; Item = item_mutable(_)
+        ),
         !:Items = [Item | !.Items]
+    ;
+        Item = item_nothing(ItemNothing),
+        ItemNothing = item_nothing_info(MaybeWarning, Context, NothingSeqNum),
+        (
+            MaybeWarning = no,
+            !:Items = [Item | !.Items]
+        ;
+            MaybeWarning = yes(Warning),
+            Warning = item_warning(MaybeOption, Msg, Term),
+            (
+                MaybeOption = yes(Option),
+                globals.lookup_bool_option(Globals, Option, Warn)
+            ;
+                MaybeOption = no,
+                Warn = yes
+            ),
+            (
+                Warn = yes,
+                Pieces = [words("Warning: "), words(Msg), nl],
+                Spec = error_spec(severity_error, phase_term_to_parse_tree,
+                    [simple_msg(get_term_context(Term), [always(Pieces)])]),
+                !:Specs = [Spec | !.Specs],
+
+                globals.lookup_bool_option(Globals, halt_at_warn, Halt),
+                (
+                    Halt = yes,
+                    !:Error = some_module_errors
+                ;
+                    Halt = no
+                )
+            ;
+                Warn = no
+            ),
+            NoWarnItemNothing = item_nothing_info(no, Context, NothingSeqNum),
+            NoWarnItem = item_nothing(NoWarnItemNothing),
+            !:Items = [NoWarnItem | !.Items]
+        )
     ).
 
 %-----------------------------------------------------------------------------%
@@ -1155,10 +1170,9 @@
             MaybeModuleNameSym),
         (
             MaybeModuleNameSym = ok1(ModuleNameSym),
-            ModuleDefn = md_module(ModuleNameSym),
-            ItemModuleDefn =
-                item_module_defn_info(ModuleDefn, Context, SeqNum),
-            Item = item_module_defn(ItemModuleDefn),
+            ItemModuleStart =
+                item_module_start_info(ModuleNameSym, Context, SeqNum),
+            Item = item_module_start(ItemModuleStart),
             MaybeItem0 = ok1(Item)
         ;
             MaybeModuleNameSym = error1(Specs),
@@ -1166,23 +1180,6 @@
         ),
         check_no_attributes(MaybeItem0, Attributes, MaybeItem)
     ;
-        Functor = "include_module",
-        ArgTerms = [ModuleNamesTerm],
-        parse_list(parse_module_name(ModuleName, VarSet), ModuleNamesTerm,
-            MaybeModuleNameSyms),
-        (
-            MaybeModuleNameSyms = ok1(ModuleNameSyms),
-            ModuleDefn = md_include_module(ModuleNameSyms),
-            ItemModuleDefn =
-                item_module_defn_info(ModuleDefn, Context, SeqNum),
-            Item = item_module_defn(ItemModuleDefn),
-            MaybeItem0 = ok1(Item)
-        ;
-            MaybeModuleNameSyms = error1(Specs),
-            MaybeItem0 = error1(Specs)
-        ),
-        check_no_attributes(MaybeItem0, Attributes, MaybeItem)
-    ;
         Functor = "end_module",
         ArgTerms = [ModuleNameTerm],
         % The name in an `end_module' declaration not inside the scope of the
@@ -1195,13 +1192,29 @@
             MaybeModuleNameSym),
         (
             MaybeModuleNameSym = ok1(ModuleNameSym),
-            ModuleDefn = md_end_module(ModuleNameSym),
+            ItemModuleEnd =
+                item_module_end_info(ModuleNameSym, Context, SeqNum),
+            Item = item_module_end(ItemModuleEnd),
+            MaybeItem0 = ok1(Item)
+        ;
+            MaybeModuleNameSym = error1(Specs),
+            MaybeItem0 = error1(Specs)
+        ),
+        check_no_attributes(MaybeItem0, Attributes, MaybeItem)
+    ;
+        Functor = "include_module",
+        ArgTerms = [ModuleNamesTerm],
+        parse_list(parse_module_name(ModuleName, VarSet), ModuleNamesTerm,
+            MaybeModuleNameSyms),
+        (
+            MaybeModuleNameSyms = ok1(ModuleNameSyms),
+            ModuleDefn = md_include_module(ModuleNameSyms),
             ItemModuleDefn =
                 item_module_defn_info(ModuleDefn, Context, SeqNum),
             Item = item_module_defn(ItemModuleDefn),
             MaybeItem0 = ok1(Item)
         ;
-            MaybeModuleNameSym = error1(Specs),
+            MaybeModuleNameSyms = error1(Specs),
             MaybeItem0 = error1(Specs)
         ),
         check_no_attributes(MaybeItem0, Attributes, MaybeItem)
Index: compiler/prog_item.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_item.m,v
retrieving revision 1.38
diff -u -b -r1.38 prog_item.m
--- compiler/prog_item.m	10 Mar 2009 05:00:28 -0000	1.38
+++ compiler/prog_item.m	2 Nov 2009 06:50:58 -0000
@@ -93,7 +93,9 @@
             % pragmas. XXX Why?
 
 :- type item
-    --->    item_module_defn(item_module_defn_info)
+    --->    item_module_start(item_module_start_info)
+    ;       item_module_end(item_module_end_info)
+    ;       item_module_defn(item_module_defn_info)
     ;       item_clause(item_clause_info)
     ;       item_type_defn(item_type_defn_info)
     ;       item_inst_defn(item_inst_defn_info)
@@ -109,6 +111,20 @@
     ;       item_mutable(item_mutable_info)
     ;       item_nothing(item_nothing_info).
 
+:- type item_module_start_info
+    --->    item_module_start_info(
+                module_start_module_name        :: module_name,
+                module_start_context            :: prog_context,
+                module_start_seq_num            :: int
+            ).
+
+:- type item_module_end_info
+    --->    item_module_end_info(
+                module_end_module_name          :: module_name,
+                module_end_context              :: prog_context,
+                module_end_seq_num              :: int
+            ).
+
 :- type item_module_defn_info
     --->    item_module_defn_info(
                 module_defn_module_defn         :: module_defn,
@@ -430,9 +446,8 @@
 %
 
 :- type pragma_type
-    %
-    % Foreign language interfacing pragmas
-    %
+    % Foreign language interfacing pragmas.
+
             % A foreign language declaration, such as C header code.
     --->    pragma_foreign_decl(
                 decl_lang               :: foreign_language,
@@ -506,9 +521,9 @@
                 foreign_enum_type_arity :: arity,
                 foreign_enum_values     :: assoc_list(sym_name, string)
             )
-    %
-    % Optimization pragmas
-    %
+
+    % Optimization pragmas.
+
     ;       pragma_type_spec(
                 tspec_pred_name         :: sym_name,
                 tspec_new_name          :: sym_name,
@@ -558,28 +573,26 @@
             )
 
     ;       pragma_trailing_info(
+                % PredName, Arity, Mode number, Trailing status.
+                % Should on appear in `.opt' or `.trans_opt' files.
                 trailing_info_p_or_f    :: pred_or_func,
                 trailing_info_name      :: sym_name,
                 trailing_info_arity     :: arity,
                 trailing_info_mode      :: mode_num,
                 trailing_info_status    :: trailing_status
             )
-                % PredName, Arity, Mode number, Trailing status.
-                % Should on appear in `.opt' or `.trans_opt' files.
 
     ;       pragma_mm_tabling_info(
+                % PredName, Arity, Mode number, MM Tabling status.
+                % Should on appear in `.opt' or `.trans_opt' files.
                 mm_tabling_info_p_or_f  :: pred_or_func,
                 mm_tabling_info_name    :: sym_name,
                 mm_tabling_info_arity   :: arity,
                 mm_tabling_info_mode    :: mode_num,
                 mm_tabling_info_status  :: mm_tabling_status
             )
-                % PredName, Arity, Mode number, MM Tabling status.
-                % Should on appear in `.opt' or `.trans_opt' files.
 
-    %
-    % Diagnostics pragmas (pragmas related to compiler warnings/errors)
-    %
+    % Diagnostics pragmas (pragmas related to compiler warnings/errors).
 
     ;       pragma_obsolete(
                 obsolete_name           :: sym_name,
@@ -588,13 +601,11 @@
             )
 
     ;       pragma_source_file(
-                pragma_source_file      :: string
                 % Source file name.
+                pragma_source_file      :: string
             )
 
-    %
-    % Evaluation method pragmas
-    %
+    % Evaluation method pragmas.
 
     ;       pragma_tabled(
                 tabled_method           :: eval_method,
@@ -619,9 +630,7 @@
                 % Typename, Arity
             )
 
-    %
-    % Purity pragmas
-    %
+    % Purity pragmas.
 
     ;       pragma_promise_equivalent_clauses(
                 eqv_clauses_name        :: sym_name,
@@ -641,9 +650,7 @@
                 % Predname, Arity
             )
 
-    %
-    % Termination analysis pragmas
-    %
+    % Termination analysis pragmas.
 
     ;       pragma_termination_info(
                 terminfo_p_or_f         :: pred_or_func,
@@ -694,9 +701,7 @@
                 mode_check_clause_arity :: arity
             )
 
-    %
     % CTGC pragmas: structure sharing / structure reuse analysis.
-    %
 
     ;       pragma_structure_sharing(
                 sharing_p_or_f          :: pred_or_func,
@@ -730,6 +735,8 @@
             % The last sym_name (reuse_optimised_name) stores the name of the
             % optimised version of the exported predicate.
 
+    % Misc pragmas.
+
     ;       pragma_require_feature_set(
                 rfs_feature_set :: set(required_feature)
             ).
@@ -857,17 +864,14 @@
 
 %-----------------------------------------------------------------------------%
 %
-% Module system
+% Module system.
 %
 
-    % This is how module-system declarations (such as imports and exports)
-    % are represented.
+    % This is how most module-system declarations (such as imports and exports,
+    % but not including the starts and ends of modules) are represented.
     %
 :- type module_defn
-    --->    md_module(module_name)
-    ;       md_end_module(module_name)
-
-    ;       md_interface
+    --->    md_interface
     ;       md_implementation
 
     ;       md_private_interface
@@ -950,6 +954,12 @@
 
 get_item_context(Item) = Context :-
     (
+        Item = item_module_start(ItemModuleStart),
+        Context = ItemModuleStart ^ module_start_context
+    ;
+        Item = item_module_end(ItemModuleEnd),
+        Context = ItemModuleEnd ^ module_end_context
+    ;
         Item = item_module_defn(ItemModuleDefn),
         Context = ItemModuleDefn ^ module_defn_context
     ;
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.50
diff -u -b -r1.50 recompilation.check.m
--- compiler/recompilation.check.m	14 Oct 2009 05:28:43 -0000	1.50
+++ compiler/recompilation.check.m	31 Oct 2009 13:54:07 -0000
@@ -936,10 +936,12 @@
         check_for_pred_or_func_item_ambiguity(no, NeedQualifier, OldTimestamp,
             VersionNumbers, PredOrFunc, Name, Args, WithType, !Info)
     ;
-        ( Item = item_mode_decl(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
+        ; Item = item_mode_decl(_)
         ; Item = item_pragma(_)
         ; Item = item_promise(_)
-        ; Item = item_module_defn(_)
         ; Item = item_instance(_)
         ; Item = item_initialise(_)
         ; Item = item_finalise(_)
Index: compiler/recompilation.version.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.version.m,v
retrieving revision 1.70
diff -u -b -r1.70 recompilation.version.m
--- compiler/recompilation.version.m	4 Nov 2009 03:44:50 -0000	1.70
+++ compiler/recompilation.version.m	4 Nov 2009 03:45:57 -0000
@@ -515,7 +515,9 @@
 
 item_to_item_id_2(Item, MaybeItemId) :-
     (
-        ( Item = item_module_defn(_)
+        ( Item = item_module_start(_)
+        ; Item = item_module_end(_)
+        ; Item = item_module_defn(_)
         ; Item = item_clause(_)
         ; Item = item_promise(_)
         ; Item = item_initialise(_)
@@ -700,6 +702,28 @@
 
 item_is_unchanged(Item1, Item2) = Unchanged :-
     (
+        Item1 = item_module_start(ItemModuleStart1),
+        ItemModuleStart1 = item_module_start_info(ModuleName, _, _),
+        (
+            Item2 = item_module_start(ItemModuleStart2),
+            ItemModuleStart2 = item_module_start_info(ModuleName, _, _)
+        ->
+            Unchanged = yes
+        ;
+            Unchanged = no
+        )
+    ;
+        Item1 = item_module_end(ItemModuleEnd1),
+        ItemModuleEnd1 = item_module_end_info(ModuleName, _, _),
+        (
+            Item2 = item_module_end(ItemModuleEnd2),
+            ItemModuleEnd2 = item_module_end_info(ModuleName, _, _)
+        ->
+            Unchanged = yes
+        ;
+            Unchanged = no
+        )
+    ;
         Item1 = item_module_defn(ItemModuleDefn1),
         ItemModuleDefn1 = item_module_defn_info(ModuleDefn, _, _),
         (
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
Index: tests/invalid/bigtest.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/bigtest.err_exp,v
retrieving revision 1.17
diff -u -b -r1.17 bigtest.err_exp
--- tests/invalid/bigtest.err_exp	14 Aug 2009 20:37:54 -0000	1.17
+++ tests/invalid/bigtest.err_exp	2 Nov 2009 15:07:38 -0000
@@ -1,3 +1,4 @@
+bigtest.m:001: Error: module should start with a `:- module' declaration.
 bigtest.m:001: Error: unrecognized declaration:
 bigtest.m:001:   export_sym(((list / 1) , ((append / 3) , member))).
 bigtest.m:001: Warning: interface for module `bigtest' does not export
@@ -7,7 +8,6 @@
 bigtest.m:001:   in its interface section(s). This would normally be a
 bigtest.m:001:   `:- pred', `:- func', `:- type', `:- inst' or `:- mode'
 bigtest.m:001:   declaration.
-bigtest.m:001: Warning: module should start with a `:- module' declaration.
 bigtest.m:002: Error: unrecognized declaration:
 bigtest.m:002:   export_pred(((append / 3) , member)).
 bigtest.m:003: Error: unrecognized declaration:
Index: tests/invalid/errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors.err_exp,v
retrieving revision 1.19
diff -u -b -r1.19 errors.err_exp
--- tests/invalid/errors.err_exp	14 Aug 2009 20:37:54 -0000	1.19
+++ tests/invalid/errors.err_exp	2 Nov 2009 15:07:47 -0000
@@ -1,7 +1,7 @@
 errors.m:001: Warning: interface for module `errors' does not export anything.
 errors.m:001: Warning: module `int' is imported using both `:- import_module'
 errors.m:001:   `:- use_module' declarations.
-errors.m:010: Warning: module should start with a `:- module' declaration.
+errors.m:010: Error: module should start with a `:- module' declaration.
 errors.m:028: Error: mode declaration for predicate
 errors.m:028:   `errors.mode_declaration_without_pred_declaration'/0
 errors.m:028:   without preceding `pred' declaration.
Index: tests/invalid/typeclass_test_1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_1.err_exp,v
retrieving revision 1.10
diff -u -b -r1.10 typeclass_test_1.err_exp
--- tests/invalid/typeclass_test_1.err_exp	14 Aug 2009 20:37:55 -0000	1.10
+++ tests/invalid/typeclass_test_1.err_exp	2 Nov 2009 15:08:00 -0000
@@ -1,4 +1,4 @@
-typeclass_test_1.m:001: Warning: module should start with a `:- module'
+typeclass_test_1.m:001: Error: module should start with a `:- module'
 typeclass_test_1.m:001:   declaration.
 typeclass_test_1.m:007: In clause for predicate `main'/2:
 typeclass_test_1.m:007:   unsatisfiable typeclass constraint:
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
Index: tests/valid/inhibit_warn_test.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/inhibit_warn_test.m,v
retrieving revision 1.1
diff -u -b -r1.1 inhibit_warn_test.m
--- tests/valid/inhibit_warn_test.m	5 Jan 1998 08:40:43 -0000	1.1
+++ tests/valid/inhibit_warn_test.m	2 Nov 2009 15:10:04 -0000
@@ -1,4 +1,4 @@
-% missing `:- module' declaration
+:- module inhibit_warn_test.
 :- pred p(int).
 :- mode p(out) is semidet. % determinism could be tighter
 p(1).
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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