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

Fix bug Muter visitor transform using wrong syntax #285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hoangatuan
Copy link
Contributor

@hoangatuan hoangatuan commented Dec 8, 2024

Problems
Passing the wrong Syntax, which leads to crashes when running muter.

Fix
We should pass the original Syntax into the length paramater

@ZevEisenberg
Copy link
Collaborator

Thanks! Any chance you could provide a project that reproduces and/or a unit test?

@hoangatuan
Copy link
Contributor Author

hoangatuan commented Dec 15, 2024

@ZevEisenberg

Given this code:

extension ClassA {

    // Verify that the input is legal
    @discardableResult
    func isInputNumberValid() -> Bool {

        let message = type == .caseA
            ? "caseAString"
            : "defaultStirng"

        return false
    }
}

When run muter:
Screenshot 2024-12-15 at 3 22 27 PM

@hoangatuan
Copy link
Contributor Author

The reason is that when running muter, we also format the _mutate project. That's why the node.description.utf8.count and mutatedSyntax.description.utf8.count is different

@hoangatuan
Copy link
Contributor Author

Also based on the Apple document, the length field should be the length of the original code. So we're passing the wrong value here

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

Successfully merging this pull request may close these issues.

2 participants