[BUG]UndefinedObject(Object)>>error:

Peter van Rooijen squeak at vanrooijen.com
Mon Oct 13 18:41:52 UTC 2003


From: "Andreas Raab" <andreas.raab at gmx.de>
> > Execute the script below in a workspace in a virgin Squeak
> > 3.6 image to see the error.
>
> I did - what's wrong with it? Why should returnBar return nil instead of
> Bar?

You mean "instead of the class Bar", correct?

The answer is that both methods should return the value of the class
variable Bar, defined in FooBase. Since nothing has been assigned to it, it
should have the value nil.

> Maybe a few comments on what the bug is would be in order - what I see
> is perfectly fine and exactly to be expected.

The scope of a class variable is the defining class, all its proper
descendents, and the instances of all those classes. The name of a class
variable, or which globals happen to exist in the image, (or the phase of
the moon, et cetera), has no influence on that. The method #returnBar in
FooSub class violates this scope rule, because it returns something else
than the value of the class variable.

If you feel I have misunderstood/misrepresented the class variable scope
rule, let me know.

Cheers,

Peter van Rooijen
Amsterdam

> Cheers,
>   - Andreas
>
>
> > -----Original Message-----
> > From: squeak-dev-bounces at lists.squeakfoundation.org
> > [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On
> > Behalf Of squeak at vanrooijen.com
> > Sent: Monday, October 13, 2003 7:40 PM
> > To: squeak-dev at lists.squeakfoundation.org
> > Subject: [BUG]UndefinedObject(Object)>>error:
> >
> >
> > Execute the script below in a workspace in a virgin Squeak
> > 3.6 image to
> > see the error.
> >
> > ----------------
> > Object
> > subclass: #FooBase
> > instanceVariableNames: ''
> > classVariableNames: 'Bar'
> > poolDictionaries: ''
> > category: 'Scope-Examples'
> > .
> > (Smalltalk at: #FooBase)
> > subclass: #FooSub
> > instanceVariableNames: ''
> > classVariableNames: ''
> > poolDictionaries: ''
> > category: 'Scope-Examples'
> > .
> > Object
> > subclass: #Bar
> > instanceVariableNames: ''
> > classVariableNames: ''
> > poolDictionaries: ''
> > category: 'Scope-Examples'
> > .
> > (Smalltalk at: #FooBase) class compile:
> > 'returnBar
> >
> > ^Bar'
> > .
> > (Smalltalk at: #FooBase) returnBar == nil
> > ifFalse: [nil error: 'FooBase: should be nil']
> > .
> > (Smalltalk at: #FooSub) class compile:
> > 'returnBar
> >
> > ^Bar'
> > .
> > (Smalltalk at: #FooSub) returnBar == nil
> > ifFalse: [nil error: 'FooSub: should be nil']
> > ----------------
> >
> > 13 October 2003 7:39:45 pm
> >
> > VM: Win32 - Squeak3.5 of '11 April 2003' [latest update: #5180]
> > Image: Squeak3.6 [latest update: #5424]
> >
> > UndefinedObject(Object)>>error:
> > Receiver: nil
> > Arguments and temporary variables:
> > aString: 'FooSub: should be nil'
> > Receiver's instance variables:
> > nil
> >
> > UndefinedObject>>DoIt
> > Receiver: nil
> > Arguments and temporary variables:
> >
> > Receiver's instance variables:
> > nil
> >
> > Compiler>>evaluate:in:to:notifying:ifFail:
> > Receiver: a Compiler
> > Arguments and temporary variables:
> > textOrStream: a ReadWriteStream
> > aContext: nil
> > receiver: nil
> > aRequestor: a TextMorphEditor
> > failBlock: [] in
> > TextMorphEditor(ParagraphEditor)>>evaluateSelection
> > methodNode: DoIt
> > Object
> > subclass: #FooBase
> > instanceVariableNames: ''
> > cla...etc...
> > method: a CompiledMethod (331)
> > value: nil
> > Receiver's instance variables:
> > sourceStream: a ReadWriteStream
> > requestor: a TextMorphEditor
> > class: UndefinedObject
> > context: nil
> > parserClass: Parser
> > cacheDoItNode: true
> >
> > [] in TextMorphEditor(ParagraphEditor)>>evaluateSelection
> > Arguments and temporary variables:
> > result: nil
> > rcvr: nil
> > ctxt: nil
> > ex: nil
> >
> >
> > --- The full stack ---
> > UndefinedObject(Object)>>error:
> > UndefinedObject>>DoIt
> > Compiler>>evaluate:in:to:notifying:ifFail:
> > [] in TextMorphEditor(ParagraphEditor)>>evaluateSelection
> >  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> > BlockContext>>on:do:
> > TextMorphEditor(ParagraphEditor)>>evaluateSelection
> > [] in PluggableTextMorph>>doIt
> > [] in PluggableTextMorph>>handleEdit:
> > TextMorphForEditView(TextMorph)>>handleEdit:
> > PluggableTextMorph>>handleEdit:
> > PluggableTextMorph>>doIt
> > Workspace(StringHolder)>>perform:orSendTo:
> > [] in MenuItemMorph>>invokeWithEvent:
> > BlockContext>>ensure:
> > CursorWithMask(Cursor)>>showWhile:
> > MenuItemMorph>>invokeWithEvent:
> > MenuItemMorph>>mouseUp:
> > MenuItemMorph>>handleMouseUp:
> > MouseButtonEvent>>sentTo:
> > MenuItemMorph(Morph)>>handleEvent:
> > MorphicEventDispatcher>>dispatchDefault:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > MenuItemMorph(Morph)>>processEvent:using:
> > MorphicEventDispatcher>>dispatchDefault:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > MenuMorph(Morph)>>processEvent:using:
> > MenuMorph(Morph)>>processEvent:
> > MenuMorph>>handleFocusEvent:
> > [] in HandMorph>>sendFocusEvent:to:clear:
> > PasteUpMorph>>becomeActiveDuring:
> > HandMorph>>sendFocusEvent:to:clear:
> > HandMorph>>sendEvent:focus:clear:
> > HandMorph>>sendMouseEvent:
> > HandMorph>>handleEvent:
> > HandMorph>>processEvents
> > [] in WorldState>>doOneCycleNowFor:
> > Array(SequenceableCollection)>>do:
> > WorldState>>handsDo:
> > WorldState>>doOneCycleNowFor:
> > WorldState>>doOneCycleFor:
> > WorldState>>doOneSubCycleFor:
> > PasteUpMorph>>doOneSubCycle
> > MenuMorph>>invokeModalAt:in:allowKeyboard:
> > MenuMorph>>invokeModal:
> > PluggableTextMorph>>yellowButtonActivity:
> > TextMorphForEditView>>mouseDown:
> > TextMorphForEditView(Morph)>>handleMouseDown:
> > MouseButtonEvent>>sentTo:
> > TextMorphForEditView(Morph)>>handleEvent:
> > MorphicEventDispatcher>>dispatchMouseDown:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > TextMorphForEditView(Morph)>>processEvent:using:
> > MorphicEventDispatcher>>dispatchMouseDown:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > TransformMorph(Morph)>>processEvent:using:
> > MorphicEventDispatcher>>dispatchMouseDown:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > PluggableTextMorph(Morph)>>processEvent:using:
> > MorphicEventDispatcher>>dispatchMouseDown:with:
> > MorphicEventDispatcher>>dispatchEvent:with:
> > SystemWindow(Morph)>>processEvent:using:
> > -- and more not shown --
> >
>
>
>



More information about the Squeak-dev mailing list