[m-dev.] for review: bug fix for type_to_term

Tyson Dowd trd at cs.mu.OZ.AU
Thu Feb 17 14:08:18 AEDT 2000


On 16-Feb-2000, Tyson Richard DOWD <trd at cs.mu.OZ.AU> wrote:
> 
> Estimated hours taken: 4
> 
> Fix a bug with type_to_term introduced recently, reported by Wim
> Vanhoof.
> 
> Equivalent types were not being handled correctly when extracting
> information about the functors.
> 
> It's not correct to simply test if a type is basically a du type,
> unless you have expanded all equivalences first.  In the code given
> the case for equivalences was unreachable.
> 
> It's better to fix the code to use type_ctor_rep to handle all cases
> anyway.

Bootcheck revealed that we need to make one more change, as we were
still having trouble with tests/hard_coded/construct.m.


Index: std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.178
diff -u -r1.178 std_util.m
--- std_util.m	2000/01/19 09:45:18	1.178
+++ std_util.m	2000/02/17 03:03:19
@@ -1165,7 +1165,6 @@
 :- pragma c_header_code("
 
 typedef struct ML_Construct_Info_Struct {
-	int vector_type;
 	int arity;
 	Word *functor_descriptor;
 	Word *argument_vector;
@@ -1536,21 +1535,26 @@
 		type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(
 			(Word *) TypeInfo);
 
-		layout_entry = type_ctor_info->type_ctor_layout[
-			info.primary_tag];
 
-		if (info.vector_type == MR_TYPE_CTOR_FUNCTORS_ENUM) {
+		if (type_ctor_info->type_ctor_rep == MR_TYPECTOR_REP_ENUM
+			|| type_ctor_info->type_ctor_rep == 
+			MR_TYPECTOR_REP_ENUM_USEREQ) {
 			/*
-			** Enumeratiors don't have tags or arguments,
+			** Enumerations don't have tags or arguments,
 			** just the enumeration value.
 			*/
 			new_data = (Word) info.secondary_tag;
 		} else {
+			layout_entry = type_ctor_info->type_ctor_layout[
+				info.primary_tag];
 			/* 
 			** It must be some sort of tagged functor.
 			*/
 
-			if (info.vector_type == MR_TYPE_CTOR_FUNCTORS_NO_TAG) {
+			if (type_ctor_info->type_ctor_rep == 
+				MR_TYPECTOR_REP_NOTAG || 
+				type_ctor_info->type_ctor_rep == 
+					MR_TYPECTOR_REP_NOTAG_USEREQ) {
 
 				/*
 				** We set term_vector to point to

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list