On Apr 15, 2018, at 9:42 AM, Ben Coman <btc@openinworld.com> wrote:
The greater prominence of Critiques in Calypso encourages me to try to clean them out.
I bumped into a false positive "Temporaries read before written." that I've condensed to the following example.
test |x| [ x := nil ] whileNil: [ x ifNil: [ x := 1] ]
Now before I log an Issue, is it feasible to be able to recognise this?
In general one would need to look at the implementor to know which blocks are always evaluated and in what order. For example, someone could have defined whileNil: as: whileNil: aBlock aBlock value In this case, it isnât a false positive since the "x := nilâ is never executed and the first use of âxâ is the âx ifNil: â¦â.
Perhaps only for common looping idioms?
It does look for common looping idioms. It treats the four whileTrue/False messages different than normal messages. It also treats ifTrue:ifFalse:/ifFalse:ifTrue: messages differently. #whileNil: isnât what I call a common looping idiom as it seems to have been added in 2007 (about 13 years after the read before written tester was written), and has 0 senders in my image. I think a better change would be adding knowledge about and:/or: combined with ifTrue:, whileTrue:, etc. For example, (self someCondition and: [(x := self value) > 0]) ifTrue: [Transcript show: x printString] In this case, x is reported as potentially read before written, but it canât be. John Brant