[Seaside] Weird behavior where writing to an instance
variableoverwrites another instance variable instead
bschroeder at procro.com
Fri Oct 15 19:23:36 CEST 2004
> I'm reposting this here with an update, as it wasn't replied to in
> squeak-dev, and I thought other Seaside users might have seen this before:
> I'm getting a very weird behavior. Using Seaside, I have a method as below:
> ACTransactionEditor>>addValidationError: aString
> ifNil: [validationErrors := OrderedCollection new].
> ^ validationErrors add: aString
> ACTransactionEditor (a subclass of WAEditDialog, for those who use
> Seaside), inherits the instance variable
> "decoration" from a superclass. I define a instance variable called
> validationErrors. In the 3rd line of
> #addValidationError:, the assignment to validationErrors actually assigns
> to decoration instead, leaving
> validationErrors unchanged. I went through the debugger a couple of times
> and can swear to it happening. It
> finally work snormally after I put a self halt into #addValidationError:.
> After that, removing the self halt,
> etc, the code still works (ie. I can't reproduce it anymore).
> Update: when I create another WAEditDialog subclass, this same problem
> happens again. Any one has experienced this? Thanks.
Are you using the instance variable declaration menu that comes up when you
save the method? There was a bug with that in Squeak 3.7.
Instance variables are accessed by index in the bytecode. When compiling a
method just after adding an instance variable, the compiler didn't consider
the superclass' variables for purposes of assigning an index. The index
given would correspond to a variable in the superclass, causing very odd
The second and subsequent times, compilation would work just fine, since the
instance variable was already there and so didn't go through the declaration
I posted a fix for this to squeak-dev on August 10th. The subject was
"[BUG][FIX] Incorrect references to auto-declared instance variables"
It should be available in the squeak-dev archives or else in BFAV. I think
that it has been added to the 3.8 update stream. If you can't find it in
one of those places, let me know - I can also send you a copy.
More information about the Seaside