[squeak-dev] Squeak4.2-10892-beta image

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed Jan 12 23:51:21 UTC 2011


Follow up on unused temps :

Wanna play with temps ? Try this :

testUnusedVariable
	self
		compiling: 'griffle | goo | ^nil'
		shouldRaise: UnusedVariable;
		compiling: 'griffle | | ^[ | goo | ]'
		shouldRaise: UnusedVariable;
		compiling: 'griffle | | [ | goo | goo := nil. goo] yourself. ^[ | goo | ]'
		shouldRaise: UnusedVariable;
		compiling: 'griffle | | [ | goo | ] yourself. ^[ | goo | goo := nil. goo]'
		shouldRaise: UnusedVariable

What happens is that Parser.scopeTable has a single entry for 'goo'.
Consequently, the last registered goo wins.
In the 3rd case, the last goo is unused, so hasRef = false, so
UnusedVariable is raised.
In the 4th case, the last goo nowHasRef, and we don't get any UnusedVariable.

Until we get a scopeTable mapping each temp of each block, we gonna
live in trouble.

Nicolas

2011/1/12 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
> 2011/1/12 Levente Uzonyi <leves at elte.hu>:
>> On Wed, 12 Jan 2011, Chris Muller wrote:
>>
>>> I've just posted a new beta image at:
>>>
>>>  ftp://ftp.squeak.org/4.2/
>>>
>>> This one does not have wrecked PackageInfo's, and has most (but not
>>> all) of the aesthetic changes for 4.2.
>>>
>>> The test suite is looking better:
>>>
>>> 'CompilerExceptionsTest>>#testUnusedVariable
>>
>> This one is new, I'd be happy if someone could have a look at it.
>>
>
> This is due to latest improvements from Eliot.
> Now the BlockNode have their own tempsMark (set by
> Parser>>#temporaryBlockVariablesFor:).
> The Parser only records top level tempsMark in Parser>>#temporaries.
>
> If you look at the code in Parser>>#removeUnusedTemps, you see some
> defensive programming
>        ((tempsMark between: 1 and: str size)
>                and: [(str at: tempsMark) = $|]) ifFalse: [^ self].
>
> But hey, the top level does not have any tempsMark, so the method
> prematurely returns without checking for some unused in the blocks.
> self
>        justTriedCompiling: 'griffle | | ^[ | goo | ]'
>        andItCorrectlyRaised: UnusedVariable.
>
> Shall we remove the tempsMark protection ?
>
> Nicolas
>



More information about the Squeak-dev mailing list