We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 01e9fe1 commit 028e29eCopy full SHA for 028e29e
tests/pyret/regression/tail-recursion-arg-order.arr
@@ -21,11 +21,22 @@ examples:
21
oops(4, 5) is working(4, 5)
22
end
23
24
+# When an argument is wrapped in a lambda to delay evaluation, mutation
25
+# in the tail recursion optimization will be unsound. Consider:
26
+
27
fun oops2(a, b):
28
foo = lam(): a end
29
if a == 1: b() else: oops2(1, foo) end
30
31
32
+# Note that
33
+#
34
+# b := lam(): a end
35
+# a := 1
36
37
+# will make the second iteration eveluates to the mutated `a` which is wrong
38
+# An easy way to fix this is to simply disable TCO in this case
39
40
fun working2(a, b):
41
42
if a == 1: b() else: working2(1, foo) + 0 end
0 commit comments