[swift-evolution] Proposal: x == 2 should not be a valid statement

Dany St-Amant dsa.mls at icloud.com
Thu Feb 11 18:10:45 CST 2016


> Le 11 févr. 2016 à 18:57, Haravikk via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> 
>> On 11 Feb 2016, at 23:52, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> This should be covered by the standard library making `==` @warn_unused_result and/or the language making @warn_unused_result the default behavior for all declarations.
> 
> I agree with this. I have kind of wondered why @warn_unused_result isn’t actually the default, as I forget to add it nine times out of ten, when in reality almost all of my methods that return something should have it. Is there an existing discussion for switching the behaviour?
> 
> But yeah, I think warning of unused comparison results should solve this issue well enough, just like misusing a function/method call.

A quick test shows that == is already @warn_unused_result
This is a inside vs outside playground issue,
playground hides all these @warn_unused_result (after all the result is display thus used)

Dany


More information about the swift-evolution mailing list