[Vm-dev] VM Maker: VMMaker.oscog-eem.2222.mcz

Eliot Miranda eliot.miranda at gmail.com
Mon Jun 5 16:46:55 UTC 2017


Hi Juan,


> On Jun 5, 2017, at 9:26 AM, Juan Vuletich <JuanVuletich at zoho.com> wrote:
> 
> Hi Eliot, Folks,
> 
> I think this commit introduces a bug:
> 
>> On 5/26/2017 10:25 PM, commits at source.squeak.org wrote:
>> primitiveMakePoint should fail if its /argument/ is not a SmallInteger or Float.  Since the primitive is on Number we know the receiver is valid, and there is no point chekcing it.  Checking the argument allows us to e.g. make 3D point using a cascade of @'s.
>> 
> 
> The reason why this is wrong is that #@ is a special selector and is just not usually sent, being replaced by bytecode 187 /* bytecodePrimMakePoint */. This means that the primitive will be called with receivers of any kind, not just Number. This breaks the 3D point use case:
> 
> Previously, doing (1 @ 2) @ 3 would create the Point(1,2) and send #@ 3. The primitive would fail because of check of receiver, and a normal send would be done, creating an appropriate 3D point.
> 
> With this change, the receiver is not validated, but the argument is. The primitive doesn't fail (arg is number) and the result is a Point with another point as x: Point(Point(1,2),3). In the explorer it shows:
> 1 at 2@3
>    x: 1 at 2
>        x: 1
>        y: 2
>    y: 3
> 
> I think that validating the argument is good, but we also need to validate receiver.

Damn, you're right.  I had forgotten about the special selector case.  The non/special selector form (a send in jotted code or a perform:) validated the receiver implicitly because the problem motive method is on Number (and Points are not numbers).  But when used as a special selector in interpreted code the receiver does still need validating.  I will fix this today.  Thanks for spotting my my mistake!

> 
> Thanks,
> 
> -- 
> Juan Vuletich
> www.cuis-smalltalk.org
> https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
> @JuanVuletich
> 
> 


More information about the Vm-dev mailing list