MutationVisitor doesn't follow assignment value
ryanb opened this issue · comments
Ryan Bates commented
Looks like the MutationVisitor#visit_assign
doesn't follow the node's value
.
def visit_assign(node)
node.copy(target: visit(node.target))
end
Is this intentional? Here's a fix.
def visit_assign(node)
node.copy(target: visit(node.target), value: visit(node.value))
end
I can make a PR if you need.
Ryan Bates commented
Looks like there are other nodes which don't visit the child nodes. Such as visit_assoc
and visit_binary
. Likely quite a few more.
Is there a reason the entire tree isn't traversed?
My use case here is I'm migrating from key-based i18n to GetText and using SyntaxTree to convert t("some.key")
to _("Some Text")
and variations on this.