diff src/mono_env.sml @ 1394:d328983dc5a6

Allow subqueries to reference aggregate-only columns of free tables; treat non-COUNT aggregate functions as possibly returning NULL
author Adam Chlipala <adam@chlipala.net>
date Sat, 15 Jan 2011 14:53:13 -0500
parents b4480a56cab7
children 6f2ea4ed573a
line wrap: on
line diff
--- a/src/mono_env.sml	Thu Jan 13 18:15:04 2011 -0500
+++ b/src/mono_env.sml	Sat Jan 15 14:53:13 2011 -0500
@@ -85,6 +85,19 @@
                 bind = fn (bound, U.Exp.RelE _) => bound + 1
                         | (bound, _) => bound}
 
+val subExpInExp =
+    U.Exp.mapB {typ = fn t => t,
+                exp = fn (xn, rep) => fn e =>
+                                  case e of
+                                      ERel xn' =>
+                                      (case Int.compare (xn', xn) of
+                                           EQUAL => #1 rep
+                                         | GREATER=> ERel (xn' - 1)
+                                         | LESS => e)
+                                    | _ => e,
+                bind = fn ((xn, rep), U.Exp.RelE _) => (xn+1, liftExpInExp 0 rep)
+                        | (ctx, _) => ctx}
+
 fun pushERel (env : env) x t eo =
     {datatypes = #datatypes env,
      constructors = #constructors env,