Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

inheritance not working? #73

Closed p6rt closed 16 years ago

p6rt commented 16 years ago

Migrated from rt.perl.org#53298 (status was 'resolved')

Searchable as RT53298$

p6rt commented 16 years ago

From @dakkar

parrot r27159, built on Linux, both x86-32 and x86-64

Running the attached program produces​:

5 Null PMC access in morph() current instr.​: '!TYPECHECKEDASSIGN' pc 6754 (src/gen_builtins.pir​:4728) called from Sub 'parrot;Bar;set' pc 255 (EVAL_13​:94) called from Sub '_block10' pc 156 (EVAL_13​:49) called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 785 (src/PCT/HLLCompiler.pir​:458) called from Sub 'parrot;PCT​::HLLCompiler;evalfiles' pc 1067 (src/PCT/HLLCompiler.pir​:587) called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1246 (src/PCT/HLLCompiler.pir​:676) called from Sub 'parrot;Perl6​::Compiler;main' pc 8860 (perl6.pir​:183)

If I uncomment the $u.boo after the re-assignment to $u, I get a "Null PMC access in get_string()"

It looks like inheritance is not working as I'd expect.

To make it "work", I have to move the 'set' method into Foo, and remove all references to Bar.

--   Dakkar - \   GPG public key fingerprint = A071 E618 DD2C 5901 9574   6FE2 40EA 9883 7519 3F88   key id = 0x75193F88

"Every group has a couple of experts. And every group has at least one idiot. Thus are balance and harmony (and discord) maintained. It's sometimes hard to remember this in the bulk of the flamewars that all of the hassle and pain is generally caused by one or two highly-motivated, caustic twits."   -- Chuq Von Rospach, about Usenet

p6rt commented 16 years ago

From @dakkar

test.p6

p6rt commented 16 years ago

From @jnthn

Hi,

dakkar (via RT) wrote​:

If I uncomment the $u.boo after the re-assignment to $u, I get a "Null PMC access in get_string()"

It looks like inheritance is not working as I'd expect.

To make it "work", I have to move the 'set' method into Foo, and remove all references to Bar.

Thanks for reporting. Initialization of attributes in parent classes hadn't been implemented; I've done that today. However, the code wasn't quite right. For attributes in parent classes, you must write them as an auto-vivification closure of the parent.

$u=Bar.new(Foo{ :x(12) });

Which is implemented now. So now your example with that fix and the one line uncommented gives​:

5 12 9

As a bonus, if you try and do it the way you originally did, you will now get a more helpful error message too.

This was done in a few patches, but r27268 is the final one that actually gets your example running.

Thanks,

Jonathan

p6rt commented 16 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 16 years ago

From @jnthn

Fixed, so closing.

p6rt commented 16 years ago

@jnthn - Status changed from 'open' to 'resolved'