I'm trying to create some classes in the repl and when I create a second class with the same attributes as the first class I'm told it's already defined.
Is this a simply a problem with the repl not handling namespaces correctly? It works as expected in a file.
Perl6 version: This is Rakudo version 2018.10 built on MoarVM version 2018.10 implementing Perl 6.c.
> class Thing {
* has $.stuff;
* }
(Thing)
> class OtherThing {
* has $.stuff;
* }
Package 'OtherThing' already has an attribute named '$!stuff'
in any scope_declarator at /home/path/.rakudobrew/moar-2018.10 /install/share/nqp/lib/Perl6/Grammar.moarvm line 1
in any term:sym<scope_declarator> at /home/path/.rakudobrew/moar-2018.10/install/share/nqp/lib/Perl6/Grammar.moarvm line 1
in any term at /home/path/.rakudobrew/moar-2018.10/install/share/nqp/lib/Perl6/Grammar.moarvm line 1
I just tried to replicate this slightly differently on my REPL, I get no error...
> class Thing { has $.stuff }
(Thing)
> class OtherThing { has $.stuff }
(OtherThing)
>
PS. I do get the same error as you when spreading the blocks over multiple lines.
This is Rakudo Star version 2018.10 built on MoarVM version 2018.10 implementing Perl 6.c.
Looks like your error is introduced by the * multi-line block logic in the REPL - I think it is a bug. Please can you report it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With