[BUG][FIX] scope of block arguments too large
Stefan Matthias Aust
sma at 3plus4.de
Wed Dec 22 10:39:42 UTC 1999
--=====================_945855582==_
Content-Type: text/plain; charset="us-ascii"
Lex answered to my posting:
>> I noticed that the following statement is NOT an compilation error - as I'd
>> suspect but evaluates to "2".
>>
>> #(1 2) do: [:i | i].
>> i
>>
>> I'm aware of that this happens because of the way, block arguments are
>> dealt with but still, it's a source of difficult to find errors.
>You're right. Maybe when closure support is added, the compiler will
>be rewritten, and at that point this scope violation will be
>fixed.
I looked into the compiler and I think it's the Encoder which behaves
incorrectly here. The Compiler (see #blockExpression) correctly
invalidates block arguments and block temporaries at the block's end and
terminates its scope. The encoder, however, if asked for a variable
binding (see #encodeVariable:ifUnknown:), ignores the scope.
I've attached a patch which seems to fix the problem. It will now emit an
error as seen here
#(1 2) do: [:i | i].
out of scope ->i
bye
--=====================_945855582==_
Content-Type: text/plain; name="Encoder-encodeVariableifUnknown"
; x-mac-type="65417070"
; x-mac-creator="43534F6D"
Content-Disposition: attachment; filename="Encoder-encodeVariableifUnknown"
Content-Transfer-Encoding: imap_stub
0,2582,2,640,0,
--=====================_945855582==_
Content-Type: text/plain; charset="us-ascii"
--
Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf.
--=====================_945855582==_--
More information about the Squeak-dev
mailing list
|