changeset 1355:ccf1d445b794

Hopeful fix to stop Especialize infinite looping
author Adam Chlipala <adam@chlipala.net>
date Tue, 21 Dec 2010 13:57:12 -0500
parents 1b286f2309bc
children 977901cb52cc
files src/especialize.sml tests/each.ur tests/each.urp tests/each.urs
diffstat 4 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/especialize.sml	Mon Dec 20 19:28:41 2010 -0500
+++ b/src/especialize.sml	Tue Dec 21 13:57:12 2010 -0500
@@ -324,13 +324,32 @@
 
                             val (fxs, xs, fvs, fin) = findSplit true (xs, typ, [], IS.empty, false)
 
+                            fun valueish (e, _) =
+                                case e of
+                                    EPrim _ => true
+                                  | ERel _ => true
+                                  | ENamed _ => true
+                                  | ECon (_, _, _, NONE) => true
+                                  | ECon (_, _, _, SOME e) => valueish e
+                                  | EFfi (_, _) => true
+                                  | EAbs _ => true
+                                  | ECAbs _ => true
+                                  | EKAbs _ => true
+                                  | ECApp (e, _) => valueish e
+                                  | EKApp (e, _) => valueish e
+                                  | ERecord xes => List.all (valueish o #2) xes
+                                  | _ => false
+
                             val vts = map (fn n => #2 (List.nth (env, n))) (IS.listItems fvs)
                             val fxs' = map (squish (IS.listItems fvs)) fxs
                         in
-                            (*Print.preface ("fxs'", Print.p_list (CorePrint.p_exp CoreEnv.empty) fxs');*)
+                            (*Print.prefaces "Func" [("name", Print.PD.string name),
+                                                   ("e", CorePrint.p_exp CoreEnv.empty e),
+                                                   ("fxs'", Print.p_list (CorePrint.p_exp CoreEnv.empty) fxs')];*)
                             if not fin
                                orelse List.all (fn (ERel _, _) => true
                                                  | _ => false) fxs'
+                               orelse List.exists (not o valueish) fxs'
                                orelse (IS.numItems fvs >= length fxs
                                        andalso IS.exists (fn n => functionInside (#2 (List.nth (env, n)))) fvs) then
                                 ((*Print.prefaces "No" [("name", Print.PD.string name),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/each.ur	Tue Dec 21 13:57:12 2010 -0500
@@ -0,0 +1,16 @@
+sequence s
+table t : { Id : int, S1 : string, S2:string, S3:string, S4:string }
+
+fun each (n : int, (f : unit -> transaction unit)) = if n > 0 then f (); each ((n-1),f) else return ()
+
+fun fill () =
+    dml (DELETE FROM t WHERE 1=1);
+    each (1,( fn () =>
+      (nv <- nextval s;
+      (dml (INSERT INTO t (Id, S1, S2, S3, S4) VALUES ({[nv]}, {["S1"]}, {["S2"]}, {["S3"]}, {["S4"]}))))
+    ));
+    return <xml>done</xml>
+
+fun main () = return <xml><body>
+    <form><submit action={fill} value="fill"/></form>
+</body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/each.urp	Tue Dec 21 13:57:12 2010 -0500
@@ -0,0 +1,3 @@
+database dbname=each
+
+each
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/each.urs	Tue Dec 21 13:57:12 2010 -0500
@@ -0,0 +1,1 @@
+val main : unit -> transaction page