muter-mutation-testing / muter

🔎 Automated mutation testing for Swift 🕳️
MIT License
491 stars 39 forks source link

RemoveSideEffectsOperator doesn't check for implicit return scenario #262

Closed hoangatuan closed 6 months ago

hoangatuan commented 6 months ago

Describe the bug

If a function uses an implicit return, RemoveSideEffectsOperator treats it as a side effect and removes it.

To Reproduce

Given this piece of code:

func calculate() -> Int {
    calculateSth()
}

func calculateSth() -> Int {
    return 2
}

Current behavior

After running Muter, here is the generated code, which cause compile error:

func calculate() -> Int {
    if ProcessInfo.processInfo.environment["AlgoService_118_23_2615"] != nil {
    } else {
        calculateSth()
    }
}

func calculateSth() -> Int {
    return 2
}

Expected behavior

Implicit return is not side effect, so we shouldn't remove it

func calculate() -> Int {
        calculateSth()
}

func calculateSth() -> Int {
        return 2
}
hoangatuan commented 6 months ago

@rakaramos @ZevEisenberg Hi, please take a look. I can help to fix this issue

rakaramos commented 6 months ago

hi @hoangatuan, which version of Muter are you using, on 16 (installed using brew) this is skipped. could you please try with that version? Or, if not possible, use muter:disable while the fix isn't there yet?

hoangatuan commented 6 months ago

Hi @rakaramos, I'm using the latest code on master branch

hoangatuan commented 6 months ago

Screenshot 2024-01-01 at 2 33 14 PM

I just checked. You've removed the logic check for implicit return in the change recently