I really don't understand why this doesn't crash

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

I really don't understand why this doesn't crash

Torsten Bergmann
 
>But I guess that should crash.

Try to debug using a #halt:

(FooClass >> #foo) halt valueWithReceiver: inst arguments: #()

This will crash the debugger with an bounds error.

Now put an additionall "self halt" into #foo as the first line

   foo
    self halt.
    Transcript show: var5 asString.
 
You will now notice that the debugger works and you can step
through. There it jumps from #withArgs:executeMethod:
(which is implemented in primitive 188) directly into #foo.

You will end up in #foo with inst as receiver and the debugger
shows that it was called on AnotherClass but found in FooClass.
see the top line of the stack:

  AnotherClass(FooClass)>>foo

But AnotherClass is not a subclass of FooClass so there are more
side effects.

So I guess primitive 188 does not do any checking and
later a random value is returned depending on what is in memory.
But I can only guess...

Bye
T.

 

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone