pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

ReNilBranchRule and ReReturnsIfTrueRule clash #17136

Open MarcusDenker opened 1 month ago

MarcusDenker commented 1 month ago

Imagine code like this:

tt
        ^ true
        ifTrue: [ self pageAt: 1 ]
        ifFalse: [ nil ]

We get " branch nil is useless" (ReNilBranchRule). Use auto-repair:

tt

    ^ true ifTrue: [ self pageAt: 1 ]

But now ReReturnsIfTrueRule complaints: "Returns value of ifTrue:/ifFalse: without ifTrue:ifFalse: block"

A solution would be for ReNilBranchRule to not complain when in a return

jecisc commented 1 month ago

I agree with the proposed solution