[m-rev.] for review: improve error reporting for initialise decls

Julien Fischer juliensf at cs.mu.OZ.AU
Sat Sep 3 01:38:16 AEST 2005


For review by anyone.

Estimated hours taken: 2
Branches: main

Improve error reporting for initialise declarations.

Make clauses in module interfaces an error rather than a warning.
Do the same for pragmas that should not occur in a module interface.

compiler/make_hlds_error.m:
	Add two new predicates that handle error reporting for items that
	should not occur in module interfaces.

compiler/make_hlds_warn.m:
	Remove the predicate for warning about items that should not occur in
	module interfaces.  It is now unused.

compiler/make_hlds_passes.m:
	Do not emit an error for export declarations that have ended up in the
	interface of a module as a result of the source-to-source
	transformation used to implement initialise declarations.

	Report initialise declarations that refer to predicates that do not
	exist directly rather than reporting that the introduced export
	pragmas are incorrect.  The latter is confusing since the pragmas
	do not appear in the source code

	Delete the XXX comment about the above.  Also fix the description of
	the transformation used to implement initialise declarations.

	Make clauses in a module interface an error rather than a warning.
	When reporting this also print out the name and arity of the predicate
	or function to which the clauses belong.

	Make it an error for pragmas that are not allowed in a module
	interface to occur in a module interface.

compiler/prog_data.m:
	Add a type that allows us to distinguish between items that originated
	with user code and those introduced by source-to-source
	transformations on the parse tree.

compiler/recompilation.version.m:
compiler/recompilation.check.m:
compiler/prog_io_pragam.m:
compiler/prog_io.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/add_pragma.m:
compiler/add_solver.m:
compiler/equiv_type.m:
compiler/intermod.m:
	Conform to the above changes.

Julien.

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.4
diff -u -r1.4 add_pragma.m
--- compiler/add_pragma.m	30 Aug 2005 04:11:46 -0000	1.4
+++ compiler/add_pragma.m	2 Sep 2005 15:14:17 -0000
@@ -23,14 +23,16 @@
 :- import_module std_util.
 :- import_module term.

-:- pred add_pragma(pragma_type::in, prog_context::in, item_status::in,
-    item_status::out, module_info::in, module_info::out, io::di, io::uo)
-    is det.
+%-----------------------------------------------------------------------------%

-:- pred add_pragma_export(sym_name::in, pred_or_func::in, list(mode)::in,
-    string::in, prog_context::in, module_info::in, module_info::out,
+:- pred add_pragma(item_origin::in, pragma_type::in, prog_context::in,
+    item_status::in, item_status::out, module_info::in, module_info::out,
     io::di, io::uo) is det.

+:- pred add_pragma_export(item_origin::in, sym_name::in, pred_or_func::in,
+    list(mode)::in, string::in, prog_context::in,
+    module_info::in, module_info::out, io::di, io::uo) is det.
+
 :- pred add_pragma_reserve_tag(sym_name::in, arity::in, import_status::in,
     prog_context::in, module_info::in, module_info::out,
     io::di, io::uo) is det.
@@ -98,6 +100,9 @@
 :- pred get_procedure_matching_declmodes(assoc_list(proc_id, proc_info)::in,
     list(mode)::in, module_info::in, proc_id::out) is semidet.

+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module backend_libs.
@@ -143,7 +148,9 @@
 :- import_module svmap.
 :- import_module varset.

-add_pragma(Pragma, Context, !Status, !ModuleInfo, !IO) :-
+%-----------------------------------------------------------------------------%
+
+add_pragma(Origin, Pragma, Context, !Status, !ModuleInfo, !IO) :-
     %
     % check for invalid pragmas in the `interface' section
     %
@@ -151,7 +158,16 @@
     pragma_allowed_in_interface(Pragma, Allowed),
     (
         Allowed = no,
-        check_not_exported(ImportStatus, Context, "`pragma' declaration", !IO)
+        (
+            Origin = user,
+            error_if_exported(ImportStatus, Context, "`pragma' declaration",
+                !IO)
+        ;
+            % We don't report this as an error as it just clutters up
+            % the compiler output - the *real* error is whatever caused
+            % the compiler to create this pragma.
+            Origin = compiler
+        )
     ;
         Allowed = yes
     ),
@@ -320,8 +336,8 @@
             Context, no_inline, [inline], !ModuleInfo, !IO)
     ).

-add_pragma_export(Name, PredOrFunc, Modes, C_Function, Context, !ModuleInfo,
-        !IO) :-
+add_pragma_export(Origin, Name, PredOrFunc, Modes, C_Function, Context,
+        !ModuleInfo, !IO) :-
     module_info_get_predicate_table(!.ModuleInfo, PredTable),
     list__length(Modes, Arity),
     (
@@ -363,14 +379,25 @@
                     !ModuleInfo)
             )
         ;
-            undefined_mode_error(Name, Arity, Context,
+            % We warn about errors in export pragmas created by the compiler
+            % as part of a source-to-source transformation.
+            (
+                Origin = user,
+                undefined_mode_error(Name, Arity, Context,
+                    "`:- pragma export' declaration", !IO),
+                module_info_incr_errors(!ModuleInfo)
+            ;
+                Origin = compiler
+            )
+        )
+    ;   (
+            Origin = user,
+            undefined_pred_or_func_error(Name, Arity, Context,
                 "`:- pragma export' declaration", !IO),
             module_info_incr_errors(!ModuleInfo)
+        ;
+            Origin = compiler
         )
-    ;
-        undefined_pred_or_func_error(Name, Arity, Context,
-            "`:- pragma export' declaration", !IO),
-        module_info_incr_errors(!ModuleInfo)
     ).

 %-----------------------------------------------------------------------------%
Index: compiler/add_solver.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_solver.m,v
retrieving revision 1.1
diff -u -r1.1 add_solver.m
--- compiler/add_solver.m	26 Jul 2005 01:56:21 -0000	1.1
+++ compiler/add_solver.m	2 Sep 2005 08:54:20 -0000
@@ -207,7 +207,7 @@
             VarSet,
             Impl
         ),
-    ToGroundRepnItem = pragma(ToGroundRepnForeignProc),
+    ToGroundRepnItem = pragma(compiler, ToGroundRepnForeignProc),
     add_item_clause(ToGroundRepnItem, !Status, Context, !ModuleInfo, !QualInfo,
         !IO),

@@ -225,7 +225,7 @@
             VarSet,
             Impl
         ),
-    ToAnyRepnItem = pragma(ToAnyRepnForeignProc),
+    ToAnyRepnItem = pragma(compiler, ToAnyRepnForeignProc),
     add_item_clause(ToAnyRepnItem, !Status, Context, !ModuleInfo, !QualInfo,
         !IO),

@@ -243,7 +243,7 @@
             VarSet,
             Impl
         ),
-    FromGroundRepnItem = pragma(FromGroundRepnForeignProc),
+    FromGroundRepnItem = pragma(compiler, FromGroundRepnForeignProc),
     add_item_clause(FromGroundRepnItem, !Status, Context, !ModuleInfo,
         !QualInfo, !IO),

@@ -261,6 +261,6 @@
             VarSet,
             Impl
         ),
-    FromAnyRepnItem = pragma(FromAnyRepnForeignProc),
+    FromAnyRepnItem = pragma(compiler, FromAnyRepnForeignProc),
     add_item_clause(FromAnyRepnItem, !Status, Context, !ModuleInfo, !QualInfo,
         !IO).
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.47
diff -u -r1.47 equiv_type.m
--- compiler/equiv_type.m	30 Aug 2005 04:11:49 -0000	1.47
+++ compiler/equiv_type.m	2 Sep 2005 08:33:34 -0000
@@ -387,10 +387,10 @@
         item_id(typeclass, ClassName - Arity), UsedTypeCtors, !Info).

 equiv_type__replace_in_item(ModuleName,
-        pragma(type_spec(PredName, B, Arity, D, E,
+        pragma(Origin, type_spec(PredName, B, Arity, D, E,
             Subst0, VarSet0, ItemIds0)),
         _Context, EqvMap, _EqvInstMap,
-        pragma(type_spec(PredName, B, Arity, D, E,
+        pragma(Origin, type_spec(PredName, B, Arity, D, E,
             Subst, VarSet, ItemIds)),
         [], !Info) :-
     (
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.174
diff -u -r1.174 intermod.m
--- compiler/intermod.m	22 Aug 2005 03:47:47 -0000	1.174
+++ compiler/intermod.m	2 Sep 2005 08:51:38 -0000
@@ -1315,7 +1315,8 @@
         ReservedTag = Body ^ du_type_reserved_tag,
         ReservedTag = yes
     ->
-        mercury_output_item(pragma(reserve_tag(Name, Arity)), Context, !IO)
+        % The pragma_origin doesn't matter here.
+        mercury_output_item(pragma(user, reserve_tag(Name, Arity)), Context, !IO)
     ;
         true
     ).
@@ -2190,7 +2191,7 @@
         read_optimization_interfaces(no, ModuleName, [ModuleName],
             set__init, [], LocalItems, no, UAError, !IO),
         IsPragmaUnusedArgs = (pred(Item::in) is semidet :-
-            Item = pragma(PragmaType) - _,
+            Item = pragma(_, PragmaType) - _,
             PragmaType = unused_args(_,_,_,_,_)
         ),
         list__filter(IsPragmaUnusedArgs, LocalItems, PragmaItems),
Index: compiler/make_hlds_error.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds_error.m,v
retrieving revision 1.1
diff -u -r1.1 make_hlds_error.m
--- compiler/make_hlds_error.m	26 Jul 2005 01:56:24 -0000	1.1
+++ compiler/make_hlds_error.m	2 Sep 2005 07:56:43 -0000
@@ -12,6 +12,8 @@
 % messages that are needed by more than one submodule.
 %

+%-----------------------------------------------------------------------------%
+
 :- module hlds__make_hlds__make_hlds_error.
 :- interface.

@@ -24,6 +26,8 @@
 :- import_module io.
 :- import_module list.

+%-----------------------------------------------------------------------------%
+
 :- pred multiple_def_error(import_status::in, sym_name::in, int::in,
     string::in, prog_context::in, prog_context::in, bool::out,
     io::di, io::uo) is det.
@@ -48,6 +52,21 @@
 :- pred maybe_undefined_pred_error(sym_name::in, int::in, pred_or_func::in,
     import_status::in, bool::in, prog_context::in, string::in,
     io::di, io::uo) is det.
+
+    % Emit an error if something is exported.  (Used to check for
+    % when things shouldn't be exported.)
+    %
+:- pred error_if_exported(import_status::in, prog_context::in, string::in,
+    io::di, io::uo) is det.
+
+    % Emit an error reporting that something should not have occurred in
+    % a module interface.
+    %
+:- pred error_is_exported(prog_context::in, string::in, io::di, io::uo)
+    is det.
+
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%

 :- implementation.

@@ -209,3 +228,21 @@
 %         suffix(".")],
 %     write_error_pieces(Context, 0, Pieces, !IO),
 %     io__set_exit_status(1, !IO).
+
+error_is_exported(Context, Message, !IO) :-
+    Error = [   words("Error:"),
+                fixed(Message),
+                words("in module interface.")],
+    write_error_pieces(Context, 0, Error, !IO),
+    io.set_exit_status(1, !IO).
+
+error_if_exported(Status, Context, Message, !IO) :-
+    ( Status = exported ->
+        error_is_exported(Context, Message, !IO)
+    ;
+        true
+    ).
+
+%----------------------------------------------------------------------------%
+:- end_module make_hlds_error.
+%----------------------------------------------------------------------------%
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.4
diff -u -r1.4 make_hlds_passes.m
--- compiler/make_hlds_passes.m	29 Aug 2005 03:22:20 -0000	1.4
+++ compiler/make_hlds_passes.m	2 Sep 2005 15:05:11 -0000
@@ -354,7 +354,7 @@
             "no pred_or_func on mode declaration")
     ).
 add_item_decl_pass_1(Item, _, !Status, !ModuleInfo, no, !IO) :-
-    Item = pragma(_).
+    Item = pragma(_, _).
 add_item_decl_pass_1(Item, _, !Status, !ModuleInfo, no, !IO) :-
     Item = promise(_, _, _, _).
 add_item_decl_pass_1(Item, Context, !Status, !ModuleInfo, no, !IO) :-
@@ -451,8 +451,8 @@
     module_add_type_defn(VarSet, Name, Args, TypeDefn, Cond, Context,
         !.Status, !ModuleInfo, !IO).
 add_item_decl_pass_2(Item, Context, !Status, !ModuleInfo, !IO) :-
-    Item = pragma(Pragma),
-    add_pragma(Pragma, Context, !Status, !ModuleInfo, !IO).
+    Item = pragma(Origin, Pragma),
+    add_pragma(Origin, Pragma, Context, !Status, !ModuleInfo, !IO).
 add_item_decl_pass_2(Item, _Context, !Status, !ModuleInfo, !IO) :-
     Item = pred_or_func(_TypeVarSet, _InstVarSet, _ExistQVars,
         PredOrFunc, SymName, TypesAndModes, _WithType, _WithInst,
@@ -476,7 +476,7 @@
             predicate_table_set_preds(Preds, PredTable0, PredTable),
             module_info_set_predicate_table(PredTable, !ModuleInfo)
         ;
-            error("make_hlds.m: can't find func declaration")
+            error("make_hlds_passes.m: can't find func declaration")
         )
     ).
 add_item_decl_pass_2(Item, _, !Status, !ModuleInfo, !IO) :-
@@ -506,24 +506,45 @@
         Body, VarSet, BodyStatus, Context, !ModuleInfo, !IO).
 add_item_decl_pass_2(Item, Context, !Status, !ModuleInfo, !IO) :-
     Item = initialise(SymName),
+    !.Status = item_status(ImportStatus, _),
+    ( ImportStatus = exported ->
+        error_is_exported(Context, "`initialise' declaration", !IO),
+        module_info_incr_errors(!ModuleInfo)
+    ;
+        true
+    ),
     %
-    % To handle a `:- initialise(initpred).' declaration we need to
+    % To handle a `:- initialise initpred.' declaration we need to
     % (1) construct a new C function name, CName, to use to export initpred,
-    % (2) add `:- export(initpred(di, uo), CName).',
+    % (2) add `:- pragma export(initpred(di, uo), CName).',
     % (3) record the initpred/cname pair in the ModuleInfo so that
     % code generation can ensure cname is called during module
     % initialisation.
     %
     module_info_new_user_init_pred(SymName, CName, !ModuleInfo),
     PragmaExportItem =
-        pragma(export(SymName, predicate, [di_mode, uo_mode], CName)),
+        pragma(compiler,
+            export(SymName, predicate, [di_mode, uo_mode], CName)),
     add_item_decl_pass_2(PragmaExportItem, Context, !Status, !ModuleInfo, !IO).

 %-----------------------------------------------------------------------------%

 add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :-
     Item = clause(VarSet, PredOrFunc, PredName, Args, Body),
-    check_not_exported(!.Status, Context, "clause", !IO),
+    ( !.Status = exported ->
+        list.length(Args, Arity),
+        %
+        % There is no point printing out the qualified name since that
+        % information is already in the context.
+        %
+        unqualify_name(PredName, UnqualifiedPredName),
+        ClauseId = simple_call_id_to_string(PredOrFunc,
+            unqualified(UnqualifiedPredName) / Arity),
+        error_is_exported(Context, "clause for " ++ ClauseId, !IO),
+        module_info_incr_errors(!ModuleInfo)
+    ;
+        true
+    ),
     GoalType = none,
     % at this stage we only need know that it's not a promise declaration
     module_add_clause(VarSet, PredOrFunc, PredName, Args, Body, !.Status,
@@ -581,7 +602,7 @@
         true
     ).
 add_item_clause(Item, !Status, Context, !ModuleInfo, !QualInfo, !IO) :-
-    Item = pragma(Pragma),
+    Item = pragma(Origin, Pragma),
     (
         Pragma = foreign_proc(Attributes, Pred, PredOrFunc,
             Vars, VarSet, PragmaImpl)
@@ -658,7 +679,7 @@
     ;
         Pragma = export(Name, PredOrFunc, Modes, C_Function)
     ->
-        add_pragma_export(Name, PredOrFunc, Modes, C_Function,
+        add_pragma_export(Origin, Name, PredOrFunc, Modes, C_Function,
             Context, !ModuleInfo, !IO)
     ;
         % Don't worry about any pragma declarations other than the
@@ -704,35 +725,44 @@
         ->
             module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
             pred_info_arg_types(PredInfo, ArgTypes),
+            pred_info_procedures(PredInfo, ProcTable),
+            ProcInfos = map.values(ProcTable),
             (
                 ArgTypes = [Arg1Type, Arg2Type],
                 type_util__type_is_io_state(Arg1Type),
-                type_util__type_is_io_state(Arg2Type)
-                % XXX We should check the arg modes and detism are correct
-                % here.  For now the arg modes and detism will be checked by
-                % the implicit `:- pragma export(...).' added for this pred.
+                type_util__type_is_io_state(Arg2Type),
+                list.member(ProcInfo, ProcInfos),
+                proc_info_maybe_declared_argmodes(ProcInfo, MaybeHeadModes),
+                MaybeHeadModes = yes(HeadModes),
+                HeadModes = [ di_mode, uo_mode ],
+                proc_info_declared_determinism(ProcInfo, MaybeDetism),
+                MaybeDetism = yes(Detism),
+                ( Detism = det ; Detism = cc_multidet )
             ->
                 module_info_user_init_pred_c_name(!.ModuleInfo, SymName,
                     CName),
                 PragmaExportItem =
-                    pragma(export(SymName, predicate, [di_mode, uo_mode],
-                    CName)),
+                    pragma(compiler,
+                        export(SymName, predicate, [di_mode, uo_mode], CName)),
                 add_item_clause(PragmaExportItem, !Status, Context,
                     !ModuleInfo, !QualInfo, !IO)
             ;
-                write_error_pieces(Context, 0, [sym_name_and_arity(SymName/2),
+                write_error_pieces(Context, 0, [words("Error:"),
+                    sym_name_and_arity(SymName/2),
                     words(" used in initialise declaration does not have " ++
                     "signature `pred(io::di, io::uo) is det'")], !IO),
                 module_info_incr_errors(!ModuleInfo)
             )
         ;
-            write_error_pieces(Context, 0, [sym_name_and_arity(SymName/2),
+            write_error_pieces(Context, 0, [words("Error:"),
+                sym_name_and_arity(SymName/2),
                 words(" used in initialise declaration has " ++
                 "multiple pred declarations.")], !IO),
             module_info_incr_errors(!ModuleInfo)
         )
     ;
-        write_error_pieces(Context, 0, [sym_name_and_arity(SymName/2),
+        write_error_pieces(Context, 0, [words("Error:"),
+            sym_name_and_arity(SymName/2),
             words(" used in initialise declaration does " ++
             "not have a corresponding pred declaration.")], !IO),
         module_info_incr_errors(!ModuleInfo)
Index: compiler/make_hlds_warn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds_warn.m,v
retrieving revision 1.2
diff -u -r1.2 make_hlds_warn.m
--- compiler/make_hlds_warn.m	8 Aug 2005 02:33:10 -0000	1.2
+++ compiler/make_hlds_warn.m	2 Sep 2005 07:09:24 -0000
@@ -13,7 +13,6 @@

 :- import_module hlds__hlds_goal.
 :- import_module hlds__hlds_module.
-:- import_module hlds__hlds_pred.
 :- import_module hlds__quantification.
 :- import_module libs__globals.
 :- import_module parse_tree__prog_data.
@@ -22,6 +21,8 @@
 :- import_module list.
 :- import_module std_util.

+%-----------------------------------------------------------------------------%
+
     % Warn about variables which occur only once but don't start with
     % an underscore, or about variables which do start with an underscore
     % but occur more than once.
@@ -47,10 +48,8 @@
 :- pred check_promise_ex_decl(prog_vars::in, promise_type::in, goal::in,
     prog_context::in, io::di, io::uo) is det.

-    % Check that clauses are not exported.
-    %
-:- pred check_not_exported(import_status::in, prog_context::in, string::in,
-    io::di, io::uo) is det.
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%

 :- implementation.

@@ -68,6 +67,8 @@
 :- import_module string.
 :- import_module varset.

+%----------------------------------------------------------------------------%
+
 maybe_warn_overlap(Warnings, VarSet, PredCallId, !IO) :-
     globals__io_lookup_bool_option(warn_overlapping_scopes,
         WarnOverlappingScopes, !IO),
@@ -702,14 +703,6 @@
     ],
     error_util__write_error_pieces(Context, 0, ErrorPieces, !IO).

-check_not_exported(Status, Context, Message, !IO) :-
-    ( Status = exported ->
-        prog_out__write_context(Context, !IO),
-        string__append_list(["Warning: ", Message, " in module interface.\n"],
-            WarningMessage),
-        report_warning(WarningMessage, !IO)
-    ;
-        true
-    ).
-
+%-----------------------------------------------------------------------------%
+:- end_module make_hlds_warn.
 %-----------------------------------------------------------------------------%
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.264
diff -u -r1.264 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	2 Sep 2005 04:21:16 -0000	1.264
+++ compiler/mercury_to_mercury.m	2 Sep 2005 08:34:04 -0000
@@ -539,7 +539,7 @@
             Context, !IO)
     ),
     io__write_string(".\n", !IO).
-mercury_output_item(_UnqualifiedItemNames, pragma(Pragma), Context, !IO) :-
+mercury_output_item(_UnqualifiedItemNames, pragma(_, Pragma), Context, !IO) :-
     maybe_output_line_number(Context, !IO),
     (
         Pragma = source_file(SourceFile),
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.109
diff -u -r1.109 module_qual.m
--- compiler/module_qual.m	29 Aug 2005 03:22:23 -0000	1.109
+++ compiler/module_qual.m	2 Sep 2005 08:35:52 -0000
@@ -303,7 +303,7 @@
     process_module_defn(ModuleDefn, !Info).
 collect_mq_info_2(pred_or_func(_, _, _, _, _, _, _, _, _, _, _, _), !Info).
 collect_mq_info_2(pred_or_func_mode(_, _, _, _, _, _, _), !Info).
-collect_mq_info_2(pragma(_), !Info).
+collect_mq_info_2(pragma(_, _), !Info).
 collect_mq_info_2(promise(_PromiseType, Goal, _ProgVarSet, _UnivVars),
         !Info) :-
     process_assert(Goal, SymNames, Success),
@@ -673,11 +673,11 @@
         !Info),
     qualify_mode_list(Modes0, Modes, !Info, !IO),
     map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !IO).
-
-module_qualify_item(pragma(Pragma0) - Context, pragma(Pragma) - Context,
-        !Info, yes, !IO) :-
+module_qualify_item(Item0, Item, !Info, yes, !IO) :-
+    Item0 = pragma(Origin, Pragma0) - Context,
     mq_info_set_error_context((pragma) - Context, !Info),
-    qualify_pragma(Pragma0, Pragma, !Info, !IO).
+    qualify_pragma(Pragma0, Pragma, !Info, !IO),
+    Item  = pragma(Origin, Pragma)  - Context.
 module_qualify_item(promise(T, G, V, U) - Context,
         promise(T, G, V, U) - Context, !Info, yes, !IO).
 module_qualify_item(nothing(A) - Context, nothing(A) - Context,
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.337
diff -u -r1.337 modules.m
--- compiler/modules.m	31 Aug 2005 04:29:00 -0000	1.337
+++ compiler/modules.m	2 Sep 2005 08:39:08 -0000
@@ -1952,7 +1952,7 @@
         report_warning("Warning: clause in module interface.\n", !IO),
         check_for_clauses_in_interface(Items0, Items, !IO)
     ;
-        Item0 = pragma(Pragma),
+        Item0 = pragma(_, Pragma),
         pragma_allowed_in_interface(Pragma, no)
     ->
         prog_out__write_context(Context, !IO),
@@ -1997,7 +1997,7 @@
         (
             Item0 = clause(_,_,_,_,_)
         ;
-            Item0 = pragma(Pragma),
+            Item0 = pragma(_, Pragma),
             pragma_allowed_in_interface(Pragma, no)
         ;
             Item0 = initialise(_)
@@ -2728,7 +2728,7 @@

 contains_tabling_pragma([Item | Items]) :-
     (
-        Item = pragma(Pragma) - _Context,
+        Item = pragma(_, Pragma) - _Context,
         Pragma = tabled(_, _, _, _, _)
     ;
         contains_tabling_pragma(Items)
@@ -5691,7 +5691,7 @@
     module_foreign_info::in, module_foreign_info::out) is det.

 get_item_foreign_code(Globals, Item, !Info) :-
-    ( Item = pragma(Pragma) - Context ->
+    ( Item = pragma(_, Pragma) - Context ->
         do_get_item_foreign_code(Globals, Pragma, Context, !Info)
     ;
         true
@@ -6814,7 +6814,7 @@

 get_fact_table_dependencies_2([], Deps, Deps).
 get_fact_table_dependencies_2([Item - _Context | Items], Deps0, Deps) :-
-    ( Item = pragma(fact_table(_SymName, _Arity, FileName)) ->
+    ( Item = pragma(_, fact_table(_SymName, _Arity, FileName)) ->
         Deps1 = [FileName | Deps0]
     ;
         Deps1 = Deps0
@@ -7117,7 +7117,7 @@
 maybe_add_foreign_import_module(ModuleName, Items0, Items) :-
     get_foreign_self_imports(Items0, Langs),
     Imports = list__map(
-        (func(Lang) = pragma(foreign_import_module(Lang, ModuleName))
+        (func(Lang) = pragma(compiler, foreign_import_module(Lang, ModuleName))
             - term__context_init),
         Langs),
     Items = Imports ++ Items0.
@@ -7258,7 +7258,7 @@
 include_in_short_interface(mode_defn(_, _, _, _, _)).
 include_in_short_interface(module_defn(_, _)).
 include_in_short_interface(instance(_, _, _, _, _, _)).
-include_in_short_interface(pragma(foreign_import_module(_, _))).
+include_in_short_interface(pragma(_, foreign_import_module(_, _))).

     % Could this item use items from imported modules.
 :- func item_needs_imports(item) = bool.
@@ -7269,7 +7269,7 @@
 item_needs_imports(inst_defn(_, _, _, _, _)) = yes.
 item_needs_imports(mode_defn(_, _, _, _, _)) = yes.
 item_needs_imports(module_defn(_, _)) = no.
-item_needs_imports(pragma(_)) = yes.
+item_needs_imports(pragma(_, _)) = yes.
 item_needs_imports(pred_or_func(_, _, _, _, _, _, _, _, _, _, _, _)) = yes.
 item_needs_imports(pred_or_func_mode(_, _, _, _, _, _, _)) = yes.
 item_needs_imports(Item @ typeclass(_, _, _, _, _, _)) =
@@ -7293,17 +7293,17 @@

 :- pred item_needs_foreign_imports(item::in, foreign_language::out) is nondet.

-item_needs_foreign_imports(pragma(export(_, _, _, _)), Lang) :-
+item_needs_foreign_imports(pragma(_, export(_, _, _, _)), Lang) :-
     foreign_language(Lang).

     % `:- pragma import' is only supported for C.
-item_needs_foreign_imports(pragma(import(_, _, _, _, _)), c).
+item_needs_foreign_imports(pragma(_, import(_, _, _, _, _)), c).
 item_needs_foreign_imports(Item @ type_defn(_, _, _, _, _), Lang) :-
     Item ^ td_ctor_defn = foreign_type(ForeignType, _, _),
     Lang = foreign_type_language(ForeignType).
-item_needs_foreign_imports(pragma(foreign_decl(Lang, _, _)), Lang).
-item_needs_foreign_imports(pragma(foreign_code(Lang, _)), Lang).
-item_needs_foreign_imports(pragma(foreign_proc(Attrs, _, _, _, _, _)),
+item_needs_foreign_imports(pragma(_, foreign_decl(Lang, _, _)), Lang).
+item_needs_foreign_imports(pragma(_, foreign_code(Lang, _)), Lang).
+item_needs_foreign_imports(pragma(_, foreign_proc(Attrs, _, _, _, _, _)),
         foreign_language(Attrs)).

 :- pred include_in_int_file_implementation(item::in) is semidet.
@@ -7318,7 +7318,7 @@
     % we won't need the local instance declarations.
     %
 include_in_int_file_implementation(typeclass(_, _, _, _, _, _)).
-include_in_int_file_implementation(pragma(foreign_import_module(_, _))).
+include_in_int_file_implementation(pragma(_, foreign_import_module(_, _))).

 :- pred make_abstract_defn(item::in, short_interface_kind::in, item::out)
     is semidet.
@@ -7434,7 +7434,7 @@
     ;
         list__filter(
             (pred((ThisItem - _)::in) is semidet :-
-                ThisItem \= pragma(foreign_import_module(_, _))
+                ThisItem \= pragma(_, foreign_import_module(_, _))
             ), !Items)
     ).

@@ -7587,7 +7587,7 @@
     ; ModuleDefn = used(_), Reorderable = no
     ; ModuleDefn = version_numbers(_, _), Reorderable = no
     ).
-reorderable_item(pragma(Pragma)) = Reorderable :-
+reorderable_item(pragma(_, Pragma)) = Reorderable :-
     ( Pragma = aditi(_, _), Reorderable = no
     ; Pragma = aditi_index(_, _, _), Reorderable = no
     ; Pragma = aditi_memo(_, _), Reorderable = no
@@ -7673,7 +7673,7 @@
     ; ModuleDefn = used(_), Reorderable = no
     ; ModuleDefn = version_numbers(_, _), Reorderable = no
     ).
-chunkable_item(pragma(Pragma)) = Reorderable :-
+chunkable_item(pragma(_, Pragma)) = Reorderable :-
     ( Pragma = aditi(_, _), Reorderable = no
     ; Pragma = aditi_index(_, _, _), Reorderable = no
     ; Pragma = aditi_memo(_, _), Reorderable = no
Index: compiler/prog_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_data.m,v
retrieving revision 1.133
diff -u -r1.133 prog_data.m
--- compiler/prog_data.m	29 Aug 2005 03:22:25 -0000	1.133
+++ compiler/prog_data.m	2 Sep 2005 14:20:26 -0000
@@ -48,6 +48,12 @@
 			item_list
 		).

+	% Did an item originate in user code or was it added by the
+	% compiler as part of a source-to-source transformation, e.g.
+	% the initialise declarations.
+	%
+:- type item_origin ---> user ; compiler.
+
 :- type item_list	==	list(item_and_context).

 :- type item_and_context ==	pair(item, prog_context).
@@ -135,6 +141,7 @@
 		%	equiv_type.m. equiv_type.m will set the field to `no'.

 	;	pragma(
+			pragma_origin		:: item_origin,
 			pragma_type		:: pragma_type
 		)

Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.244
diff -u -r1.244 prog_io.m
--- compiler/prog_io.m	29 Aug 2005 03:22:25 -0000	1.244
+++ compiler/prog_io.m	2 Sep 2005 08:40:45 -0000
@@ -711,7 +711,7 @@
 		% file name
 		%
 		MaybeFirstItem = ok(FirstItem, _),
-		FirstItem = pragma(source_file(NewSourceFileName))
+		FirstItem = pragma(_, source_file(NewSourceFileName))
 	->
 		read_first_item(DefaultModuleName, NewSourceFileName,
 			ModuleName, Messages, Items, MaybeSecondTerm, Error,
@@ -898,7 +898,7 @@
 	% parsing context according.  Next, unless the item is a
 	% `pragma source_file' declaration, insert it into the item list.
 	% Then continue looping.
-	( Item = pragma(source_file(NewSourceFileName)) ->
+	( Item = pragma(_, source_file(NewSourceFileName)) ->
 		SourceFileName = NewSourceFileName,
 		ModuleName = ModuleName0
 	; Item = module_defn(_VarSet, module(NestedModuleName)) ->
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.85
diff -u -r1.85 prog_io_pragma.m
--- compiler/prog_io_pragma.m	14 Aug 2005 03:20:40 -0000	1.85
+++ compiler/prog_io_pragma.m	2 Sep 2005 08:47:02 -0000
@@ -114,7 +114,7 @@
         (
             SourceFileTerm = term__functor(term__string(SourceFile), [], _)
         ->
-            Result = ok(pragma(source_file(SourceFile)))
+            Result = ok(pragma(user, source_file(SourceFile)))
         ;
             Result = error("string expected in `:- pragma " ++
                 "source_file' declaration", SourceFileTerm)
@@ -247,7 +247,7 @@
         PragmaTerms = [ImportTerm],
         sym_name_and_args(ImportTerm, Import, [])
     ->
-        Result = ok(pragma(foreign_import_module(c, Import)))
+        Result = ok(pragma(user, foreign_import_module(c, Import)))
     ;
         Result = error("wrong number of arguments or invalid " ++
             "module name in `:- pragma c_import_module' " ++
@@ -261,7 +261,7 @@
         sym_name_and_args(ImportTerm, Import, [])
     ->
         ( parse_foreign_language(LangTerm, Language) ->
-            Result = ok(pragma(
+            Result = ok(pragma(user,
                 foreign_import_module(Language, Import)))
         ;
             Result = error("invalid foreign language in " ++
@@ -452,7 +452,7 @@
         ( parse_foreign_language(LangTerm, ForeignLanguage) ->
             ( HeaderTerm = term__functor(term__string( HeaderCode), [], _) ->
                 DeclCode = foreign_decl(ForeignLanguage, IsLocal, HeaderCode),
-                Result = ok(pragma(DeclCode))
+                Result = ok(pragma(user, DeclCode))
             ;
                 ErrMsg = "-- expected string for foreign declaration code",
                 Result = error(string__append(InvalidDeclStr, ErrMsg),
@@ -482,7 +482,7 @@
     Check1 = (func(PTerms1, ForeignLanguage) = Res is semidet :-
         PTerms1 = [Just_Code_Term],
         ( Just_Code_Term = term__functor(term__string(Just_Code), [], _) ->
-            Res = ok(pragma(foreign_code(ForeignLanguage, Just_Code)))
+            Res = ok(pragma(user, foreign_code(ForeignLanguage, Just_Code)))
         ;
             ErrMsg = "-- expected string for foreign code",
             Res = error(string__append(InvalidDeclStr, ErrMsg), ErrorTerm)
@@ -744,7 +744,7 @@
                 PredAndArgModesResult = ok(PredName - PredOrFunc, ArgModes),
                 (
                     FlagsResult = ok(Attributes),
-                    Result = ok(pragma(import(PredName, PredOrFunc,
+                    Result = ok(pragma(user, import(PredName, PredOrFunc,
                         ArgModes, Attributes, Function)))
                 ;
                     FlagsResult = error(Msg, Term),
@@ -773,7 +773,7 @@
                 PredAndModesResult),
             (
                 PredAndModesResult = ok(PredName - PredOrFunc, Modes),
-                Result = ok(pragma(export(PredName, PredOrFunc, Modes,
+                Result = ok(pragma(user, export(PredName, PredOrFunc, Modes,
                     Function)))
             ;
                 PredAndModesResult = error(Msg, Term),
@@ -858,7 +858,7 @@
         convert_int_list(UnusedArgsTerm, UnusedArgsResult),
         UnusedArgsResult = ok(UnusedArgs)
     ->
-        Result = ok(pragma(unused_args(PredOrFunc, PredName, Arity, ModeNum,
+        Result = ok(pragma(user, unused_args(PredOrFunc, PredName, Arity, ModeNum,
             UnusedArgs)))
     ;
         Result = error("error in `:- pragma unused_args'", ErrorTerm)
@@ -905,9 +905,10 @@
                         UnqualName, type_subst(TVarSet, TypeSubn),
                         SpecializedName)
                 ),
-                Result = ok(pragma(type_spec(PredName, SpecializedName, Arity,
+                TypeSpecPragma = type_spec(PredName, SpecializedName, Arity,
                     MaybePredOrFunc, MaybeModes, TypeSubn, TVarSet,
-                    set__init)))
+                    set__init),
+                Result = ok(pragma(user, TypeSpecPragma))
             ;
                 Result = error("expected type substitution in " ++
                     "`:- pragma type_spec' declaration", TypeSubnTerm)
@@ -936,7 +937,8 @@
         (
             NameArityResult = ok(PredName, Arity),
             ( FileNameTerm = term__functor(term__string(FileName), [], _) ->
-                Result = ok(pragma(fact_table(PredName, Arity, FileName)))
+                Result = ok(pragma(user,
+                    fact_table(PredName, Arity, FileName)))
             ;
                 Result = error("expected string for fact table filename",
                     FileNameTerm)
@@ -983,7 +985,7 @@
                 convert_int_list(AttributesTerm, AttributeResult),
                 (
                     AttributeResult = ok(Attributes),
-                    Result = ok(pragma(aditi_index(PredName, PredArity,
+                    Result = ok(pragma(user, aditi_index(PredName, PredArity,
                         index_spec(IndexType, Attributes))))
                 ;
                     AttributeResult = error(_, AttrErrorTerm),
@@ -1108,7 +1110,7 @@
             TerminationTerm = term__functor(term__atom("cannot_loop"), [], _),
             MaybeTerminationInfo = yes(cannot_loop(unit))
         ),
-        Result0 = ok(pragma(termination_info(PredOrFunc, PredName,
+        Result0 = ok(pragma(user, termination_info(PredOrFunc, PredName,
             ModeList, MaybeArgSizeInfo, MaybeTerminationInfo)))
     ->
         Result = Result0
@@ -1144,7 +1146,7 @@
             TerminationTerm = term__functor(term__atom("cannot_loop"), [], _),
             MaybeTerminationInfo = yes(cannot_loop(unit))
         ),
-        Result0 = ok(pragma(termination2_info(PredOrFunc, PredName,
+        Result0 = ok(pragma(user, termination2_info(PredOrFunc, PredName,
             ModeList, SuccessArgSizeInfo, FailureArgSizeInfo,
             MaybeTerminationInfo)))
     ->
@@ -1218,7 +1220,7 @@
             ThrowStatus = conditional
         )
     ->
-        Result = ok(pragma(exceptions(PredOrFunc, PredName,
+        Result = ok(pragma(user, exceptions(PredOrFunc, PredName,
             Arity, ModeNum, ThrowStatus)))
     ;
         Result = error("error in `:- pragma exceptions'", ErrorTerm)
@@ -1267,7 +1269,7 @@
         (
             NameArityResult = ok(PredName, Arity),
             call(MakePragma, PredName, Arity, Pragma),
-            Result = ok(pragma(Pragma))
+            Result = ok(pragma(user, Pragma))
         ;
             NameArityResult = error(ErrorMsg, _),
             Result = error(ErrorMsg, PredAndArityTerm)
@@ -1592,7 +1594,7 @@
         (
             Error = no,
             varset__coerce(VarSet0, VarSet),
-            Result = ok(pragma(foreign_proc(Flags, PredName, PredOrFunc,
+            Result = ok(pragma(user, foreign_proc(Flags, PredName, PredOrFunc,
                 PragmaVars, VarSet, PragmaImpl)))
         ;
             Error = yes(ErrorMessage),
@@ -1666,7 +1668,8 @@
                     "expected argument tabling method", MaybeArgMethods),
                 (
                     MaybeArgMethods = ok(ArgMethods),
-                    Result = ok(pragma(tabled(eval_memo(specified(ArgMethods)),
+                    Result = ok(pragma(user,
+                        tabled(eval_memo(specified(ArgMethods)),
                         PredName, Arity, MaybePredOrFunc, MaybeModes)))
                 ;
                     MaybeArgMethods = error(Msg, Term),
@@ -1674,7 +1677,8 @@
                 )
             ;
                 MaybeSpec = no,
-                Result = ok(pragma(tabled(TablingType, PredName, Arity,
+                Result = ok(pragma(user,
+                    tabled(TablingType, PredName, Arity,
                     MaybePredOrFunc, MaybeModes)))
             )
         ;
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.15
diff -u -r1.15 recompilation.check.m
--- compiler/recompilation.check.m	30 Aug 2005 04:11:58 -0000	1.15
+++ compiler/recompilation.check.m	2 Sep 2005 08:47:39 -0000
@@ -952,7 +952,7 @@
 		VersionNumbers, PredOrFunc, Name, Args, WithType, !Info).
 check_for_ambiguities(_, _, _,
 		pred_or_func_mode(_, _, _, _, _, _, _) - _, !Info).
-check_for_ambiguities(_, _, _, pragma(_) - _, !Info).
+check_for_ambiguities(_, _, _, pragma(_, _) - _, !Info).
 check_for_ambiguities(_, _, _, promise(_, _, _, _) - _, !Info).
 check_for_ambiguities(_, _, _, module_defn(_, _) - _, !Info).
 check_for_ambiguities(_, _, _, instance(_, _, _, _, _, _) - _, !Info).
Index: compiler/recompilation.version.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.version.m,v
retrieving revision 1.21
diff -u -r1.21 recompilation.version.m
--- compiler/recompilation.version.m	29 Aug 2005 03:22:26 -0000	1.21
+++ compiler/recompilation.version.m	2 Sep 2005 08:48:57 -0000
@@ -369,7 +369,7 @@
 			GatheredItems0, GatheredItems),
 		!:Info = !.Info ^ gathered_items := GatheredItems
 	;
-		Item = pragma(PragmaType),
+		Item = pragma(_, PragmaType),
 		is_pred_pragma(PragmaType, yes(PredOrFuncId))
 	->
 		PragmaItems = !.Info ^ pragma_items,
@@ -566,7 +566,7 @@

 	% We need to handle these separately because some pragmas
 	% may affect a predicate and a function.
-item_to_item_id_2(pragma(_), no).
+item_to_item_id_2(pragma(_, _), no).
 item_to_item_id_2(promise(_, _, _, _), no).
 item_to_item_id_2(Item, yes(item_id((typeclass), ClassName - ClassArity))) :-
 	Item = typeclass(_, _, ClassName, ClassVars, _, _),
@@ -703,8 +703,8 @@
 	% declarations because the names of the variables are used
 	% to find the corresponding variables in the predicate or
 	% function type declaration.
-item_is_unchanged(pragma(PragmaType1), Item2) = Result :-
-	( Item2 = pragma(PragmaType2) ->
+item_is_unchanged(pragma(_, PragmaType1), Item2) = Result :-
+	( Item2 = pragma(_, PragmaType2) ->
 		(
 			PragmaType1 = type_spec(Name, SpecName, Arity,
 				MaybePredOrFunc, MaybeModes, TypeSubst1,
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.173
diff -u -r1.173 Mmakefile
--- tests/invalid/Mmakefile	29 Aug 2005 03:22:31 -0000	1.173
+++ tests/invalid/Mmakefile	2 Sep 2005 09:16:56 -0000
@@ -125,6 +125,7 @@
 	nested_impl_in_int \
 	no_exports \
 	not_a_switch \
+	not_in_interface \
 	nullary_ho_func_error \
 	occurs \
 	overloading \
Index: tests/invalid/bad_initialise_decl.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/bad_initialise_decl.err_exp,v
retrieving revision 1.1
diff -u -r1.1 bad_initialise_decl.err_exp
--- tests/invalid/bad_initialise_decl.err_exp	29 Aug 2005 03:22:32 -0000	1.1
+++ tests/invalid/bad_initialise_decl.err_exp	2 Sep 2005 15:16:20 -0000
@@ -1,17 +1,8 @@
-Making Mercury/cs/bad_initialise_decl.c
-Error: file `bad_initialise_decl.m' contains the wrong module.
-Expected module `bad_initialise_decl', found module `initialise_decl'.
-bad_initialise_decl.m:011: Warning: source file `bad_initialise_decl.m' contains module named `initialise_decl': :- module initialise_decl.
-bad_initialise_decl.m:026: `i1'/2 used in initialise declaration does not have
-bad_initialise_decl.m:026:   signature `pred(io::di, io::uo) is det'
-bad_initialise_decl.m:027: Error: `:- pragma export' declaration for `i2'/2
-bad_initialise_decl.m:027:   specifies non-existent mode.
-bad_initialise_decl.m:030: In clause for predicate `initialise_decl.i1/2':
-bad_initialise_decl.m:030:   in argument 2 of call to predicate `io.print/3':
-bad_initialise_decl.m:030:   type error: variable `STATE_VARIABLE_IO_0' has type `(some [T] T)',
-bad_initialise_decl.m:030:   expected type was `(io.state)'.
-bad_initialise_decl.m:030: In clause for predicate `initialise_decl.i1/2':
-bad_initialise_decl.m:030:   in implicit state variable unification:
-bad_initialise_decl.m:030:   type error in unification of variable `STATE_VARIABLE_IO'
-bad_initialise_decl.m:030:   and variable `STATE_VARIABLE_IO_1'.
-** Error making `Mercury/cs/bad_initialise_decl.c'.
+bad_initialise_decl.m:019: Error: `initialise' declaration in module interface.
+bad_initialise_decl.m:019: Error: `i2'/2 used in initialise declaration does
+bad_initialise_decl.m:019:   not have signature `pred(io::di, io::uo) is det'
+bad_initialise_decl.m:026: Error: `i1'/2 used in initialise declaration does
+bad_initialise_decl.m:026:   not have signature `pred(io::di, io::uo) is det'
+bad_initialise_decl.m:027: Error: `i3'/2 used in initialise declaration does
+bad_initialise_decl.m:027:   not have a corresponding pred declaration.
+For more information, try recompiling with `-E'.
Index: tests/invalid/bad_initialise_decl.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/bad_initialise_decl.m,v
retrieving revision 1.1
diff -u -r1.1 bad_initialise_decl.m
--- tests/invalid/bad_initialise_decl.m	29 Aug 2005 03:22:32 -0000	1.1
+++ tests/invalid/bad_initialise_decl.m	2 Sep 2005 09:51:46 -0000
@@ -1,22 +1,22 @@
 %-----------------------------------------------------------------------------%
-% initialise_decl.m
+% bad_initialise_decl.m
 % Ralph Becket <rafe at cs.mu.oz.au>
 % Wed Aug 17 14:25:01 EST 2005
 % vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
 %
-% Test the `:- initialise initpred' directive.
+% Test error messages for the `:- initialise initpred' directive.
 %
 %-----------------------------------------------------------------------------%

-:- module initialise_decl.
+:- module bad_initialise_decl.

 :- interface.

 :- import_module io.

+:- pred main(io::di, io::uo) is det.

-
-:- pred main(io :: di, io :: uo) is det.
+:- initialise i2.

 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -24,13 +24,13 @@
 :- implementation.

 :- initialise i1.
-:- initialise i2.
+:- initialise i3.

 :- pred i1(T::di, T::uo) is det.
-i1(!IO) :- io.print("This is the first initialise pred, i1/2.\n", !IO).
+i1(X, X).

 :- pred i2(io::in, io::out) is det.
-i2(!IO) :- io.print("This is the second initialise pred, i2/2.\n", !IO).
+i2(!IO).

 main(!IO) :- io.print("This is main/2.\n", !IO).

Index: tests/invalid/not_in_interface.err_exp
===================================================================
RCS file: tests/invalid/not_in_interface.err_exp
diff -N tests/invalid/not_in_interface.err_exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/not_in_interface.err_exp	2 Sep 2005 15:16:47 -0000
@@ -0,0 +1,5 @@
+not_in_interface.m:011: Error: `initialise' declaration in module interface.
+not_in_interface.m:015: Error: `pragma' declaration in module interface.
+not_in_interface.m:018: Error: clause for predicate `foo/2' in module
+not_in_interface.m:018:   interface.
+For more information, try recompiling with `-E'.
Index: tests/invalid/not_in_interface.m
===================================================================
RCS file: tests/invalid/not_in_interface.m
diff -N tests/invalid/not_in_interface.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/not_in_interface.m	2 Sep 2005 09:52:34 -0000
@@ -0,0 +1,22 @@
+%
+% Tests that we write out error messages for things
+% that shouldn't occur in module interfaces.
+%
+:- module not_in_interface.
+
+:- interface.
+
+:- import_module io.
+
+:- initialise bar/2.
+
+:- pred bar(io::di, io::uo) is det.
+
+:- pragma inline(foo/2).
+:- pred foo(int::in, int::out) is det.
+
+foo(X, X).
+
+:- implementation.
+
+bar(!IO).
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list