You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala> ir"val x = 42; println(x.toDouble)" fix_rewrite { case ir"($n:Int).toDouble" => ir"$n.toDouble+1" }
java.lang.StackOverflowError
on the other hand, this one does not exhibit the problem:
scala> ir"val x = 42; println(x.toDouble)" fix_rewrite { case ir"($n:Int).toDouble" => ir"$n.toDouble" }
Rewrite rules did not converge after 8 iterations.
ir"""{
val x_0 = 42;
scala.Predef.println(x_0.toDouble)
}"""
The text was updated successfully, but these errors were encountered:
Note: the problem also appears when rewrite is used instead of fix_rewrite.
This is because the term grows in size and thus the top-down transformation never finishes.
LPTK
changed the title
Some fixed point rewritings diverge instead of stopping on a recursion limit
Some rewritings diverge instead of stopping on a recursion limit
Sep 20, 2017
A good fix would be to make rewrite use a bottom-up traversal by default, which does not have this problem. Top-down transformations are either more dangerous (if they are allowed to recurse into freshly-rewritten terms) or less powerful in term of expressiveness (if they are not).
Bottom-up rewriting is safer (less prone to divergence) and often more
natural, so it’s a better default behavior.
Note that this is potentially a breaking change, though I expect that
most code that uses `rewrite` will still work.
Currently some tests are broken; they will be fixed in the next commit.
See:
on the other hand, this one does not exhibit the problem:
The text was updated successfully, but these errors were encountered: