[m-rev.] for review: fix mantis bug 46

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Feb 19 19:09:18 AEDT 2008


I am bootchecking this fix now.

Zoltan.

Fix Mantis bug #46, which was a compiler abort about a negative stack slot
in the __Unify__ predicate of a notag type type wrapper around a dummy type.

compiler/unify_proc.m:
	When creating unify and compare predicates for notag types, generate
	code that always considers the values to be equal if the type inside
	the notag wrapper is a dummy type.

cvs diff: Diffing .
Index: unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.201
diff -u -b -r1.201 unify_proc.m
--- unify_proc.m	11 Feb 2008 21:26:12 -0000	1.201
+++ unify_proc.m	19 Feb 2008 08:03:21 -0000
@@ -799,9 +799,20 @@
                 Goal = true_goal_with_context(Context),
                 quantify_clause_body([X, Y], Goal, Context, Clause, !Info)
             ;
-                ( DuTypeKind = du_type_kind_general
-                ; DuTypeKind = du_type_kind_notag(_, _, _)
-                ),
+                DuTypeKind = du_type_kind_notag(_, ArgType, _),
+                IsDummyType = check_dummy_type(ModuleInfo, ArgType),
+                (
+                    IsDummyType = is_dummy_type,
+                    % Treat this type as if it were a dummy type itself.
+                    Goal = true_goal_with_context(Context),
+                    quantify_clause_body([X, Y], Goal, Context, Clause, !Info)
+                ;
+                    IsDummyType = is_not_dummy_type,
+                    generate_du_unify_proc_body(Ctors, X, Y, Context, Clause,
+                        !Info)
+                )
+            ;
+                DuTypeKind = du_type_kind_general,
                 generate_du_unify_proc_body(Ctors, X, Y, Context, Clause,
                     !Info)
             )
@@ -1047,7 +1058,7 @@
             Res, X, Y, Context, Clause, !Info)
     ;
         (
-            TypeBody = hlds_du_type(Ctors0, _, _, DuTypeKind, _, _, _, _),
+            TypeBody = hlds_du_type(Ctors, _, _, DuTypeKind, _, _, _, _),
             (
                 ( DuTypeKind = du_type_kind_mercury_enum
                 ; DuTypeKind = du_type_kind_foreign_enum(_)
@@ -1058,20 +1069,22 @@
                 DuTypeKind = du_type_kind_direct_dummy,
                 generate_dummy_compare_proc_body(Res, X, Y, Context, Clause,
                     !Info)
+
             ;
-                ( DuTypeKind = du_type_kind_general
-                ; DuTypeKind = du_type_kind_notag(_, _, _)
-                ),
-                module_info_get_globals(ModuleInfo, Globals),
-                globals.lookup_bool_option(Globals,
-                    lexically_order_constructors, LexicalOrder),
+                DuTypeKind = du_type_kind_notag(_, ArgType, _),
+                IsDummyType = check_dummy_type(ModuleInfo, ArgType),
                 (
-                    LexicalOrder = yes,
-                    list.sort(compare_ctors_lexically, Ctors0, Ctors)
+                    IsDummyType = is_dummy_type,
+                    % Treat this type as if it were a dummy type itself.
+                    generate_dummy_compare_proc_body(Res, X, Y, Context,
+                        Clause, !Info)
                 ;
-                    LexicalOrder = no,
-                    Ctors = Ctors0
-                ),
+                    IsDummyType = is_not_dummy_type,
+                    generate_du_compare_proc_body(Type, Ctors, Res, X, Y,
+                        Context, Clause, !Info)
+                )
+            ;
+                DuTypeKind = du_type_kind_general,
                 generate_du_compare_proc_body(Type, Ctors, Res, X, Y,
                     Context, Clause, !Info)
             )
@@ -1448,15 +1461,24 @@
     prog_var::in, prog_var::in, prog_var::in, prog_context::in,
     clause::out, unify_proc_info::in, unify_proc_info::out) is det.
 
-generate_du_compare_proc_body(Type, Ctors, Res, X, Y, Context, Clause,
+generate_du_compare_proc_body(Type, Ctors0, Res, X, Y, Context, Clause,
         !Info) :-
+    info_get_module_info(!.Info, ModuleInfo),
+    module_info_get_globals(ModuleInfo, Globals),
+    globals.lookup_bool_option(Globals, lexically_order_constructors,
+        LexicalOrder),
+    (
+        LexicalOrder = yes,
+        list.sort(compare_ctors_lexically, Ctors0, Ctors)
+    ;
+        LexicalOrder = no,
+        Ctors = Ctors0
+    ),
     (
         Ctors = [],
         unexpected(this_file, "compare for type with no functors")
     ;
         Ctors = [_ | _],
-        info_get_module_info(!.Info, ModuleInfo),
-        module_info_get_globals(ModuleInfo, Globals),
         globals.lookup_int_option(Globals, compare_specialization,
             CompareSpec),
         list.length(Ctors, NumCtors),
cvs diff: Diffing notes
--------------------------------------------------------------------------
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