Update of /cvsroot/monetdb/pathfinder/compiler/semantics
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19085/semantics

Modified Files:
        subtyping.c typecheck.brg 
Log Message:

 -- `none' should be a subtype of every other type.  (This partially
    reverts a checkin I did some time ago.)  `none' is something
    like an illegal, non-existing type, so it seems odd that it is
    a subtype of every other type.  It is, however, consistent with
    `none' being the identity with respect to `|' (choice of two types):

      ( t1 | t2 )  <:  t3    ==>   t1 <: t3 /\ t2 <: t3

    now, since `t1 | none' == `t1':

      (t1 | none)  <:  t1    ==>   t1 <: t1 /\ none <: t1

    This fixes bug #1579510 (at least, it improves Pathfinder's
    behavior; a nice fix would print a more meaningful message).

 -- There was a rewrite rule in coreopt.brg which rewrote

      main (..., e) 

    into
    
      empty

    if the entire expression had static type empty.  This rewrite rule

     (a) never did anything until now, since the main() node does not
         have a static type, hence, could never be a subtype of empty
         and
     (b) would have broken the compilation if it did anything.
         Rewriting the main() node into an empty() node makes the whole
         thing an invalid Core tree!

    My typing changes turned (a) into its opposite and I removed the
    rewrite to avoid (b).


Index: subtyping.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/subtyping.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- subtyping.c 3 Jan 2007 12:33:01 -0000       1.42
+++ subtyping.c 20 Feb 2007 14:25:48 -0000      1.43
@@ -1156,6 +1156,18 @@
  * - 0 indicates not (t1 <: t2)
  * - 1 indicates t1 <: t2
  * - _ indicates <: must be decided using Antimirov's algorithm.
+ *
+ * NOTE: `none' is a subtype of all other types (but no other type is
+ *       a subtype of `none').  This is an outcome of the XOBE algorithm
+ *       and seems to be most consistent with choice types:
+ *
+ *         ( t1 | t2 )  <:  t3   ==>  t1 <: t3 /\ t2 <: t3.
+ *
+ *       i.e.,
+ *
+ *         (t1 | none)  <:  t1   ==>  t1 <: t1 /\ none <: t1.
+ *
+ *       (Note that `none' is the identity with respect to `|'.)
  */
 #define _ -1
 
@@ -1175,7 +1187,7 @@
                      o p m             t A m m r g m b i e a o l t d x   o t g
                      n t e             e n i i i e a l n a m d e t o e p m m m
                      e y d ? + * , | & m y c c c r l e g n e e m r c t i m t 
t*/
- [ty_none   ]      ={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
+ [ty_none   ]      ={1,1,_,_,_,_,_,_,_,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 
}
 ,[ty_empty  ]      ={0,1,_,1,_,1,_,_,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
 ,[ty_named  ]      ={_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ 
}
 ,[ty_opt    ]      ={0,_,_,_,_,_,_,_,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
@@ -1232,7 +1244,7 @@
                      o p m             t A m m r g m b i e a o l t d x   o t g
                      n t e             e n i i i e a l n a m d e t o e p m m m
                      e y d ? + * , | & m y c c c r l e g n e e m r c t i m t 
t*/
- [ty_none   ]      ={1,0,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
+ [ty_none   ]      ={1,0,_,_,_,_,_,_,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
 ,[ty_empty  ]      ={0,1,_,_,_,_,_,_,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}
 ,[ty_named  ]      ={_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0,0 
}
 ,[ty_opt    ]      ={0,_,_,_,_,_,_,_,_,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
}

Index: typecheck.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/typecheck.brg,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- typecheck.brg       20 Feb 2007 12:06:53 -0000      1.54
+++ typecheck.brg       20 Feb 2007 14:25:48 -0000      1.55
@@ -416,7 +416,18 @@
             reduce (kids[1], nts[1]);
             reduce (kids[0], nts[0]);
 
-            if (PFty_subtype (TY(R(p)), PFty_star (PFty_item ())))
+            if (PFty_subtype (TY(R(p)), PFty_star (PFty_none ())))
+                /*
+                 * Not really okay, but we let it go through with
+                 * a warning: the query *statically* evaluated to
+                 * the error type (none).
+                 *
+                 * NOTE: `none' is a subtype of all other types (but
+                 *       nothing is a subtype of `none').  Hence,
+                 *       do this check before any other check.
+                 */
+                PFinfo (OOPS_WARNING, "query will always return an error");
+            else if (PFty_subtype (TY(R(p)), PFty_star (PFty_item ())))
                 /* okay, this is a normal query */
                 ;
             else if (PFty_subtype (TY(R(p)), PFty_star (PFty_stmt ())))
@@ -425,14 +436,10 @@
             else if (PFty_subtype (TY(R(p)), PFty_star (PFty_docmgmt ())))
                 /* okay, this is a document management query */
                 ;
-            else if (PFty_subtype (TY(R(p)), PFty_none ()))
-                /* not really okay, but we let it go through with
-                 * a warning: the query *statically* evaluated to
-                 * the error type (none). */
-                PFinfo (OOPS_WARNING, "query will always return an error");
             else
                 PFoops (OOPS_TYPECHECK,
-                        "illegal combination of query and update features");
+                        "illegal combination of query and update features "
+                        "(result type is `%s')", PFty_str (TY(R(p))));
 
             break;
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to