[BUG] LiteralVariableNode>>sizeCodeForStorePop:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] LiteralVariableNode>>sizeCodeForStorePop:

Igor Stasenko
Open a browser, pick any class, and enter the code:

foo
        WorldState := nil

then accept it.
The compiler goes into an infinite recursion in
LiteralVariableNode>>sizeCodeForStorePop:.

sizeCodeForStorePop: encoder
        self reserve: encoder.
        ^(key isVariableBinding and: [key isSpecialWriteBinding])
                ifTrue: [(self sizeCodeForStorePop: encoder) + encoder sizePop]
                ifFalse: [encoder sizeStorePopLiteralVar: index]


(Pharo 1.1 having no such problem - it accepts a code without any warnings.. )

AFAIK, it should either warn or throw an error that assignment is not
possible into read-only variable binding.

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] LiteralVariableNode>>sizeCodeForStorePop:

Eliot Miranda-2
Oops.  Find fix attached:

LiteralVariableNode methods for code generation (new scheme)
sizeCodeForStorePop: encoder
self reserve: encoder.
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [(self sizeCodeForStore: encoder) + encoder sizePop]
ifFalse: [encoder sizeStorePopLiteralVar: index]

Arguably the compiler should issue an error, but the error is raised at run-time because the generated code sends value: (correct) rather than using any of the store lit var bytecodes.  If a compiler error is wanted (my preference) then find attached:

LiteralVariableNode methods for testing
assignmentCheck: encoder at: location
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [location]
ifFalse: [-1]

On Thu, May 20, 2010 at 2:16 AM, Igor Stasenko <[hidden email]> wrote:
Open a browser, pick any class, and enter the code:

foo
       WorldState := nil

then accept it.
The compiler goes into an infinite recursion in
LiteralVariableNode>>sizeCodeForStorePop:.

sizeCodeForStorePop: encoder
       self reserve: encoder.
       ^(key isVariableBinding and: [key isSpecialWriteBinding])
               ifTrue: [(self sizeCodeForStorePop: encoder) + encoder sizePop]
               ifFalse: [encoder sizeStorePopLiteralVar: index]


(Pharo 1.1 having no such problem - it accepts a code without any warnings.. )

AFAIK, it should either warn or throw an error that assignment is not
possible into read-only variable binding.

--
Best regards,
Igor Stasenko AKA sig.





LiteralVariableNode-sizeCodeForStorePop.st (566 bytes) Download Attachment
LiteralVariableNode-assignmentCheckat.st (410 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] LiteralVariableNode>>sizeCodeForStorePop:

Eliot Miranda-2


On Thu, May 20, 2010 at 9:04 AM, Eliot Miranda <[hidden email]> wrote:
Oops.  Find fix attached:

LiteralVariableNode methods for code generation (new scheme)
sizeCodeForStorePop: encoder
self reserve: encoder.
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [(self sizeCodeForStore: encoder) + encoder sizePop]
ifFalse: [encoder sizeStorePopLiteralVar: index]

Arguably the compiler should issue an error, but the error is raised at run-time because the generated code sends value: (correct) rather than using any of the store lit var bytecodes.  If a compiler error is wanted (my preference) then find attached:


Except that this is wrong:
 
LiteralVariableNode methods for testing
assignmentCheck: encoder at: location
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [location]
ifFalse: [-1]

It will cause an error when assigning to IslandVariables in Croquet.  So it must be

LiteralVariableNode methods for testing
assignmentCheck: encoder at: location
^(key isVariableBinding and: [key canAssign not])
ifTrue: [location]
ifFalse: [-1]

Find attached.
 

On Thu, May 20, 2010 at 2:16 AM, Igor Stasenko <[hidden email]> wrote:
Open a browser, pick any class, and enter the code:

foo
       WorldState := nil

then accept it.
The compiler goes into an infinite recursion in
LiteralVariableNode>>sizeCodeForStorePop:.

sizeCodeForStorePop: encoder
       self reserve: encoder.
       ^(key isVariableBinding and: [key isSpecialWriteBinding])
               ifTrue: [(self sizeCodeForStorePop: encoder) + encoder sizePop]
               ifFalse: [encoder sizeStorePopLiteralVar: index]


(Pharo 1.1 having no such problem - it accepts a code without any warnings.. )

AFAIK, it should either warn or throw an error that assignment is not
possible into read-only variable binding.

--
Best regards,
Igor Stasenko AKA sig.






LiteralVariableNode-assignmentCheckat.st (402 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] LiteralVariableNode>>sizeCodeForStorePop:

Eliot Miranda-2
in inbox as Compiler-eem.140

On Thu, May 20, 2010 at 9:15 AM, Eliot Miranda <[hidden email]> wrote:


On Thu, May 20, 2010 at 9:04 AM, Eliot Miranda <[hidden email]> wrote:
Oops.  Find fix attached:

LiteralVariableNode methods for code generation (new scheme)
sizeCodeForStorePop: encoder
self reserve: encoder.
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [(self sizeCodeForStore: encoder) + encoder sizePop]
ifFalse: [encoder sizeStorePopLiteralVar: index]

Arguably the compiler should issue an error, but the error is raised at run-time because the generated code sends value: (correct) rather than using any of the store lit var bytecodes.  If a compiler error is wanted (my preference) then find attached:


Except that this is wrong:
 
LiteralVariableNode methods for testing
assignmentCheck: encoder at: location
^(key isVariableBinding and: [key isSpecialWriteBinding])
ifTrue: [location]
ifFalse: [-1]

It will cause an error when assigning to IslandVariables in Croquet.  So it must be

LiteralVariableNode methods for testing
assignmentCheck: encoder at: location
^(key isVariableBinding and: [key canAssign not])
ifTrue: [location]
ifFalse: [-1]

Find attached.
 

On Thu, May 20, 2010 at 2:16 AM, Igor Stasenko <[hidden email]> wrote:
Open a browser, pick any class, and enter the code:

foo
       WorldState := nil

then accept it.
The compiler goes into an infinite recursion in
LiteralVariableNode>>sizeCodeForStorePop:.

sizeCodeForStorePop: encoder
       self reserve: encoder.
       ^(key isVariableBinding and: [key isSpecialWriteBinding])
               ifTrue: [(self sizeCodeForStorePop: encoder) + encoder sizePop]
               ifFalse: [encoder sizeStorePopLiteralVar: index]


(Pharo 1.1 having no such problem - it accepts a code without any warnings.. )

AFAIK, it should either warn or throw an error that assignment is not
possible into read-only variable binding.

--
Best regards,
Igor Stasenko AKA sig.






Reply | Threaded
Open this post in threaded view
|

Re: [BUG] LiteralVariableNode>>sizeCodeForStorePop:

Igor Stasenko
Thanks for fix, Eliot.

It was a foolish to try to compile an assignment to read-only var binding.
But sure thing, its not an excuse for compiler. :)

On 20 May 2010 19:32, Eliot Miranda <[hidden email]> wrote:

> in inbox as Compiler-eem.140
>
> On Thu, May 20, 2010 at 9:15 AM, Eliot Miranda <[hidden email]>
> wrote:
>>
>>
>> On Thu, May 20, 2010 at 9:04 AM, Eliot Miranda <[hidden email]>
>> wrote:
>>>
>>> Oops.  Find fix attached:
>>> LiteralVariableNode methods for code generation (new scheme)
>>> sizeCodeForStorePop: encoder
>>> self reserve: encoder.
>>> ^(key isVariableBinding and: [key isSpecialWriteBinding])
>>> ifTrue: [(self sizeCodeForStore: encoder) + encoder sizePop]
>>> ifFalse: [encoder sizeStorePopLiteralVar: index]
>>> Arguably the compiler should issue an error, but the error is raised at
>>> run-time because the generated code sends value: (correct) rather than using
>>> any of the store lit var bytecodes.  If a compiler error is wanted (my
>>> preference) then find attached:
>>
>> Except that this is wrong:
>>
>>>
>>> LiteralVariableNode methods for testing
>>> assignmentCheck: encoder at: location
>>> ^(key isVariableBinding and: [key isSpecialWriteBinding])
>>> ifTrue: [location]
>>> ifFalse: [-1]
>>
>> It will cause an error when assigning to IslandVariables in Croquet.  So
>> it must be
>> LiteralVariableNode methods for testing
>> assignmentCheck: encoder at: location
>> ^(key isVariableBinding and: [key canAssign not])
>> ifTrue: [location]
>> ifFalse: [-1]
>> Find attached.
>>
>>>
>>> On Thu, May 20, 2010 at 2:16 AM, Igor Stasenko <[hidden email]>
>>> wrote:
>>>>
>>>> Open a browser, pick any class, and enter the code:
>>>>
>>>> foo
>>>>        WorldState := nil
>>>>
>>>> then accept it.
>>>> The compiler goes into an infinite recursion in
>>>> LiteralVariableNode>>sizeCodeForStorePop:.
>>>>
>>>> sizeCodeForStorePop: encoder
>>>>        self reserve: encoder.
>>>>        ^(key isVariableBinding and: [key isSpecialWriteBinding])
>>>>                ifTrue: [(self sizeCodeForStorePop: encoder) + encoder
>>>> sizePop]
>>>>                ifFalse: [encoder sizeStorePopLiteralVar: index]
>>>>
>>>>
>>>> (Pharo 1.1 having no such problem - it accepts a code without any
>>>> warnings.. )
>>>>
>>>> AFAIK, it should either warn or throw an error that assignment is not
>>>> possible into read-only variable binding.
>>>>
>>>> --
>>>> Best regards,
>>>> Igor Stasenko AKA sig.
>>>>
>>>
>>
>
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.