[squeak-dev] Bug with valueWithReceiver:arguments:

Frederic Pluquet fpluquet at ulb.ac.be
Sun Oct 26 11:57:53 UTC 2008


Hello,
I found a fondamental bug in Squeak and Pharo. The next code

11 / 2

gives the fraction (11/2). It's correct. But the next code

(SmallInteger>>#/) valueWithReceiver: 11 arguments: {2}

gives 1 !

The problem is the method valueWithReceiver:arguements: is used hugely with
method wrappers...

After long time of debugging, I found a point to debug: this method don't
have the good behavior with compiled methods having a primitive that fails
and executes some code after (as in SmallInteger>>#/ method when the
division don't give a whole integer). In fact, when I send this message, the
vm executes normally the compiled method but, in place of returns simply the
good result, seems to rerun the the compiled method with other arguments
(completly wrong) and returns so a wrong result.

For example,
(SmallInteger>>#/) valueWithReceiver: 11 arguments: {2}

has the following execution trace :

2 isZero
|  2 = 0
|  returns: false
returns: false
2 isMemberOf: SmallInteger
|  2 class
|  returns: SmallInteger
|  SmallInteger == SmallInteger
|  returns: true
returns: true
Fraction numerator: 101 denominator: 2
|  Fraction new
|  |  Fraction basicNew
|  |  returns: a Fraction instance
|  |  (a Fraction instance) initialize
|  |  returns: a Fraction instance
|  returns: a Fraction instance
|  a Fraction instance setNumerator: 101 denominator: 2
|  |  2 = 0
|  |  returns: false
|  |  101 asInteger
|  |  returns: 101
|  |  2 asInteger
|  |  returns: 2
|  |  2 abs
|  |  |  2 < 0
|  |  |  returns: false
|  |  returns: 2
|  |  2 < 0
|  |  returns: false
|  returns: (101/2)
returns: (101/2)
(101/2) reduced
|  101 = 0
|  returns: false
|  101 gcd: 2
|  |  101 = 0
|  |  returns: false
|  |  2 \\ 101
|  |  returns: 2
|  |  2 = 0
|  |  returns: false
|  |  101 \\ 2
|  |  returns: 1
|  |  1 = 0
|  |  returns: false
|  |  2 \\ 1
|  |  returns: 0
|  |  0 = 0
|  |  returns: true
|  |  1 abs
|  |  |  1 < 0
|  |  |  returns: false
|  |  returns: 1
|  returns: 1
|  101 // 1
|  returns: 101
|  2 // 1
|  returns: 2
|  2 = 1
|  returns: false
|  Fraction numerator: 101 denominator: 2
|  |  Fraction new
|  |  |  Fraction basicNew
|  |  |  returns: a Fraction instance
|  |  |  (a Fraction instance) initialize
|  |  |  returns: a Fraction instance
|  |  returns: a Fraction instance
|  |  (a Fraction instance) setNumerator: 101 denominator: 2
|  |  |  2 = 0
|  |  |  returns: false
|  |  |  101 asInteger
|  |  |  returns: 101
|  |  |  2 asInteger
|  |  |  returns: 2
|  |  |  2 abs
|  |  |  |  2 < 0
|  |  |  |  returns: false
|  |  |  returns: 2
|  |  |  2 < 0
|  |  |  returns: false
|  |  returns: (101/2)
|  returns: (101/2)
returns: (101/2)
2 isZero
|  2 = 0
|  returns: false
returns: false
false isMemberOf: SmallInteger
|  false class
|  returns: False
|  False == SmallInteger
|  returns: false
returns: false


Please help me to fix this bug. I really need it works fine !

Fréd
-- 
Frédéric Pluquet
Université Libre de Bruxelles (ULB)
Assistant
http://www.ulb.ac.be/di/fpluquet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20081026/506a35d1/attachment.htm


More information about the Squeak-dev mailing list