# New Ticket Created by Roger Browne
# Please include the string: [perl #36411]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36411 >
The following PIR (attached as "script.pir", and also included here)
fails under Parrot 0.2.1 (Fedora Core 3, Intel x86):
.sub main @MAIN
$P1 = newclass "PARENT_1"
addattribute $P1, "foo" #1
$P2 = subclass $P1, "PARENT_2"
addattribute $P2, "foo" #2
$P3 = subclass $P2, "CHILD"
addattribute $P3, "bar"
$P0 = new "CHILD"
$P97 = new .String
set $P97, "Hello from attribute foo"
setattribute $P0, "foo", $P97 #3
$P98 = new .String
set $P98, "Hello from attribute bar"
setattribute $P0, "bar", $P98 #4
$P99 = getattribute $P0, "foo" #5
print $P99
print "\n"
end
.end
This prints "Hello from attribute bar" when it should print "Hello from
attribute foo".
The bug disappears if line #4 is commented out, suggesting that
"setattribute foo" (line #3) and "setattribute bar" (line #4) are both
storing into the same slot that is retrieved by "getattribute foo".
The bug also disappears if either line #1 or line #2 is commented out,
suggesting that this bug is exposed by multiple layers of inheritance.
Here's the inheritance hierarchy:
PARENT_1 # adds attribute 'foo'
^
|
PARENT_2 # adds attribute 'foo', hiding the inherited one
^
|
CHILD # adds attribute 'bar'
Regards,
Roger Browne
[
script.pir < 1K ]
.sub main @MAIN
$P1 = newclass "PARENT_1"
addattribute $P1, "foo" #1
$P2 = subclass $P1, "PARENT_2"
addattribute $P2, "foo" #2
$P3 = subclass $P2, "CHILD"
addattribute $P3, "bar"
$P0 = new "CHILD"
$P97 = new .String
set $P97, "Hello from attribute foo"
setattribute $P0, "foo", $P97 #3
$P98 = new .String
set $P98, "Hello from attribute bar"
setattribute $P0, "bar", $P98 #4
$P99 = getattribute $P0, "foo" #5
print $P99
print "\n"
end
.end