pharo icon indicating copy to clipboard operation
pharo copied to clipboard

asMutator can produce illegal selector

Open Ducasse opened this issue 6 years ago • 2 comments

"#_ asMutator >>> #_:" "#foo:: asMutator >>> #'foo::'"

the implementation should be improved

Ducasse avatar Sep 15 '19 13:09 Ducasse

There is no explicit precondition in asMutator. The implicit one is: self preCondition: [self isSelector & self isBinary not]

I personally believe this implicit precondition follows from the comment: Return a setter message from a getter message, as a getter message is a selector and is not binary.

I suggest to close this one.

Perhaps it is time for a "should we add a notion of pre and post conditions for methods", as I have seen several issues in here which is basically about pre conditions not being clear.

kasperosterbye avatar Oct 02 '19 08:10 kasperosterbye

So we should add the precondition in an explicit manner.

... 
       (self isSelector & self isBinary not) ifFalse: [ ^ self ] 

Ducasse avatar Jul 30 '24 07:07 Ducasse