REBOL3 tracker
  0.9.12 beta
Ticket #0001050 User: anonymous

Project:



rss
TypeBug Statustested Date5-Jul-2009 00:50
Versionalpha 50 CategoryDatatype Submitted byBrianH
PlatformAll Severitymajor Prioritynormal

Summary APPEND object! [self: 1] overrides self
Description When you append 'self to an object, the field self is added and is no longer protected. See the code.

This is related to #595.
Example code
>> a: context []
== make object! [
]
>> in a 'self
== none
>> do in a [self]
== make object! [
]
>> do bind [self] a
== make object! [
]
>> a/self
** Script error: cannot access self in path a/self
>> append a [self: 1]
== make object! [
    self: 1
]
>> get in a 'self
== 1
>> a/self
== 1

Assigned ton/a Fixed inalpha 98 Last Update6-May-2010 08:46


Comments
(0001233)
BrianH
5-Jul-2009 00:56

The word 'self in objects is protected with PROTECT and hidden with PROTECT/hide. BIND or IN of a block will go past the hiding (in just this case, not for hidden words in general), but otherwise the word 'self is like any other hidden word.

If you add a new word with the same name as a hidden word then all new attempts to bind a word of that name to the object will bind to the new word. All existing code that was bound to the old word will stay bound to the old word.

If you need IN or BIND of blocks to get the original binding of 'self, don't override 'self :)
(0002331)
BrianH
6-May-2010 08:46

As of alpha 98 APPEND will no longer allow you to override 'self, even for contexts that don't bind 'self anyways.
>> append context [] [self: 1]
** Script error: cannot set/unset self - it is protected

Date User Field Action Change
6-May-2010 08:46 BrianH Comment : 0002331 Added -
6-May-2010 08:45 BrianH Fixedin Modified => alpha 98
6-May-2010 08:45 BrianH Category Modified => Datatype
6-May-2010 08:45 BrianH Severity Modified not a bug => major
6-May-2010 08:45 BrianH Status Modified dismissed => tested
5-Jul-2009 00:59 BrianH Comment : 0001233 Modified -
5-Jul-2009 00:57 BrianH Description Modified -
5-Jul-2009 00:56 BrianH Comment : 0001233 Added -
5-Jul-2009 00:50 BrianH Code Modified -
5-Jul-2009 00:50 BrianH Severity Modified minor => not a bug
5-Jul-2009 00:50 BrianH Status Modified submitted => dismissed
5-Jul-2009 00:50 BrianH Ticket Added -