rqlrewrite.py
branchstable
changeset 9188 0677e03077fb
parent 9187 8406bef5d5f2
child 9189 9448215c73c4
--- a/rqlrewrite.py	Wed Jul 24 16:49:40 2013 +0200
+++ b/rqlrewrite.py	Wed Jul 24 16:55:24 2013 +0200
@@ -303,7 +303,7 @@
             myunion.append(myrqlst)
             # in-place rewrite + annotation / simplification
             lcheckdef = [({var: 'X'}, rqlexprs) for var, rqlexprs in lcheckdef]
-            self.rewrite(myrqlst, lcheckdef, lchecksolutions, kwargs)
+            self.rewrite(myrqlst, lcheckdef, kwargs)
             _add_noinvariant(noinvariant, restricted, myrqlst, nbtrees)
         if () in localchecks:
             select.set_possible_types(localchecks[()])
@@ -311,13 +311,14 @@
             _add_noinvariant(noinvariant, restricted, select, nbtrees)
         self.annotate(union)
 
-    def rewrite(self, select, snippets, solutions, kwargs, existingvars=None):
+    def rewrite(self, select, snippets, kwargs, existingvars=None):
         """
         snippets: (varmap, list of rql expression)
                   with varmap a *tuple* (select var, snippet var)
         """
         self.select = select
-        self.solutions = solutions
+        # remove_solutions used below require a copy
+        self.solutions = solutions = select.solutions[:]
         self.kwargs = kwargs
         self.u_varname = None
         self.removing_ambiguity = False
@@ -342,6 +343,7 @@
             select, solutions, newsolutions))
         if len(newsolutions) > len(solutions):
             newsolutions = self.remove_ambiguities(snippets, newsolutions)
+            assert newsolutions
         select.solutions = newsolutions
         add_types_restriction(self.schema, select)
 
@@ -611,7 +613,6 @@
                 exists = var.references()[0].scope
                 exists.add_constant_restriction(var, 'is', etype, 'etype')
         # recompute solutions
-        #select.annotated = False # avoid assertion error
         self.compute_solutions()
         # clean solutions according to initial solutions
         return remove_solutions(self.solutions, self.select.solutions,