# New Ticket Created by  mt1957 
# Please include the string:  [perl #130338]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=130338 >


Hi,

Recently after pulling the newest rakudo/moarvm (2016.11-238-g2f502b4 
built on MoarVM version 2016.11-41-gd2139b5 implementing Perl 6.c) I saw 
errors in my code which compiled ok before. This is difficult to golf 
down because it disappears when used in another context. So better 
explain my way of coding.

The error I get now is

/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/xt/Sxml/driver-authentication.t
 
..
===SORRY!===
Type 'MongoDB::Server' is not declared
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):152
------>             my MongoDB::Server⏏ $server .= new(
Malformed my
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):152
------>             my MongoDB::⏏Server $server .= new(


The module in question has the following at the top

use v6.c;

use MongoDB::Server;
use MongoDB::Database;
use MongoDB::Collection;
use MongoDB::Uri;
use MongoDB::Wire;
use MongoDB::Authenticate::Credential;
use MongoDB;

use BSON::Document;
use Semaphore::ReadersWriters;

#-------------------------------------------------------------------------------
unit package MongoDB:auth<https://github.com/MARTIMM>;

#-------------------------------------------------------------------------------
class Client {
...
   my MongoDB::Server $server .= new(
     :client(self), :$server-name, :$loop-time
   );
....
}


The server class is defined likewise as

use v6.c;

use MongoDB;
use MongoDB::Server::Monitor;
use MongoDB::Server::Socket;
use MongoDB::Authenticate::Credential;
use MongoDB::Authenticate::Scram;

use BSON::Document;
use Semaphore::ReadersWriters;
use Auth::SCRAM;

#-------------------------------------------------------------------------------
unit package MongoDB:auth<https://github.com/MARTIMM>;

#-------------------------------------------------------------------------------
class Server { ... }


When e.g. the line 'use MongoDB::Uri' is moved above that of 
MongoDB::Server (in the Client module) another error is returned;

Type 'MongoDB::Uri' is not declared
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):99
------>     my MongoDB::Uri⏏ $uri-obj .= new(:$!uri);
Malformed my
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):99
------>     my MongoDB::⏏Uri $uri-obj .= new(:$!uri);


Now I found out that when the 'unit package' line is moved above the use 
statements, the error disappears. Can anyone shed some light over this? 
I know that use statements can be used within package, module and class 
to narrow the scope of definitions but I can't remember anything which 
could explain this behavior.

Thanks,
Marcel



Reply via email to