Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutationVisitor doesn't follow assignment value #373

Open
ryanb opened this issue May 16, 2023 · 1 comment
Open

MutationVisitor doesn't follow assignment value #373

ryanb opened this issue May 16, 2023 · 1 comment

Comments

@ryanb
Copy link

ryanb commented May 16, 2023

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.

@ryanb
Copy link
Author

ryanb commented May 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant