Skip to content
Snippets Groups Projects
Commit 28f52708 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Make sure a Tree is not its own parent

parent 52c37827
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,12 @@ object PrinterHelpers { ...@@ -54,7 +54,12 @@ object PrinterHelpers {
nary(ts).print(nctx) nary(ts).print(nctx)
case t: Tree => case t: Tree =>
val nctx2 = nctx.copy(parents = nctx.current :: nctx.parents, current = t) val parents = if (nctx.current == t) {
nctx.parents
} else {
nctx.current :: nctx.parents
}
val nctx2 = nctx.copy(parents = parents, current = t)
printer.pp(t)(nctx2) printer.pp(t)(nctx2)
case p: Printable => case p: Printable =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment