On Tue, May 1, 2012 at 6:09 PM, Mariano Martinez Peck <[email protected] > wrote:
> Hi guys. I noticed stef did this issue: > http://code.google.com/p/pharo/issues/detail?id=5642 > However, now I have the following test that fails in Pharo 2.0 but works > fine in 1.4: > > | string context | > string := 'test'. > context := [self class. string asUppercase] asContext. > self assert: (context tempNamed: 'string') = 'test' > > the current implementation of #tempNamed: is: > > tempNamed: aName > "Returns the value of the temporaries, aName." > "Implementation notes: temporary initialization in blocks simply uses > pushNil to allocate and initialize each temp. So if one inspects [|a|a:=2] > and sends it self method symbolic you get: > > 13 <8F 00 00 05> closureNumCopied: 0 numArgs: 0 bytes 17 to 21 > 17 <73> pushConstant: nil > 18 <77> pushConstant: 2 > 19 <81 40> storeIntoTemp: 0 > 21 <7D> blockReturn > 22 <7C> returnTop > > And when we check self asContext pc we get 17, which is *before* the > nil is pushed. Therefore we should pay attention when querying a temporary > if the temporary allocation was executed." > > | index | > index := (self tempNames indexOf: aName). > ^ index >= stackp > Maybe the solution is to use #> rather than #>= ? > ifTrue: [ nil] > ifFalse: [self tempAt: (self tempNames indexOf: aName)] > > > and previously it was: > > tempNamed: aName > ^self tempAt: (self tempNames indexOf: aName) > > > ideas? > > > -- > Mariano > http://marianopeck.wordpress.com > > -- Mariano http://marianopeck.wordpress.com
