]> hydra-www.ietfng.org Git - dyna2/commitdiff
()
authorTim Vieira <tim.f.vieira@gmail.com>
Tue, 16 Jul 2013 18:35:39 +0000 (14:35 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Tue, 16 Jul 2013 18:35:39 +0000 (14:35 -0400)
src/Dyna/Backend/Python/interpreter.py
test/repl/recursion-limit.dynadoc [new file with mode: 0644]

index 587e4ee5400da12045ff80cd86c2427c61bb7063..99fdbfdb64bbada918054423569d2e2985a583f4 100644 (file)
@@ -367,7 +367,7 @@ class Interpreter(object):
                     init,
                     query)
 
-            fn = '$rule/%s' % (len(args) + 1)
+            fn = '$rule/%s' % len(args)
             if self.agg_name[fn] is None:
                 self.new_fn(fn, ':=')
 
diff --git a/test/repl/recursion-limit.dynadoc b/test/repl/recursion-limit.dynadoc
new file mode 100644 (file)
index 0000000..b20995a
--- /dev/null
@@ -0,0 +1,29 @@
+% in this example we forget to include a base case so we end up recursing
+% forever, but thanks to the python runtime this throws an exception and we
+% catch it.
+
+> :- backchain f/1.
+| f(X) = f(X-1).
+
+% add this rule separately to make sure its an initialization failure
+> a = f(3).
+
+> rules
+
+Rules
+=====
+  0: f(X) = f(X-1).
+  1: a = f(3).  <-- uninitialized
+
+> sol
+
+Solution empty.
+
+Errors
+======
+Uninitialized rules
+===================
+Failed to initialize rule:
+    a = f(3).
+  due to `maximum recursion depth exceeded`
+    a = f(3)=?.