Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the perl6 repl not distinguishing between two different classes?

Tags:

raku

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
like image 617
jmcneirney Avatar asked Dec 23 '18 14:12

jmcneirney


Video Answer


1 Answers

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?

like image 188
p6steve Avatar answered Nov 15 '22 21:11

p6steve