Skip Menu |
Report information

Date: Tue, 8 Nov 2016 13:42:13 +0100
To: rakudobug [...] perl.org
Subject: placement of use statement
From: mt1957 <mt1957 [...] gmail.com>
Download (untitled) / with headers
text/plain 1.1k
Hi, in rakudo 2016.10-249-gb84158c built on MoarVM version 2016.10-37-gf769569 implementing Perl 6.c, I've seen the following problem. When a use statement was placed as the first one, the class was not recognized and I got the following error(in this case MongoDB::Client which is loaded with 'use MongoDB::Client'): ===SORRY!=== Error while compiling /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/t/Test-support.pm6 (Test-support) Type 'MongoDB::Client' is not declared at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/t/Test-support.pm6 (Test-support):119 ------> n ( Int :$server = 1 --> MongoDB::Client⏏ ) { When I move the statement one line below another use statement the error still comes back. Only when the line is below all other use statements the error disappears as if the other use statements cancels out the the MongoDB::Client definition. This is a situation which I've not seen anywhere else and I do not know if there is something wrong in the code or not, Maybe it has something to do with the recent changes in lexical module loading. Anyways, the statement is placed somewhere else and the project can continue. Regards, Marcel
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.3k
On Tue, 08 Nov 2016 04:42:32 -0800, mt1957@gmail.com wrote: Show quoted text
> Hi, > > in rakudo 2016.10-249-gb84158c built on MoarVM version > 2016.10-37-gf769569 implementing Perl 6.c, I've seen the following problem. > > When a use statement was placed as the first one, the class was not > recognized and I got the following error(in this case MongoDB::Client > which is loaded with 'use MongoDB::Client'): > > ===SORRY!=== Error while compiling > /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/t/Test-support.pm6 > (Test-support) > Type 'MongoDB::Client' is not declared > at > /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/t/Test-support.pm6 > (Test-support):119 > ------> n ( Int :$server = 1 --> MongoDB::Client⏏ ) { > > When I move the statement one line below another use statement the error > still comes back. Only when the line is below all other use statements > the error disappears as if the other use statements cancels out the the > MongoDB::Client definition. > > This is a situation which I've not seen anywhere else and I do not know > if there is something wrong in the code or not, Maybe it has something > to do with the recent changes in lexical module loading. > > Anyways, the statement is placed somewhere else and the project can > continue. > > Regards, > Marcel >
Can you provide a code sample showing the issue? -- Will "Coke" Coleda
From: mt1957 <mt1957 [...] gmail.com>
Subject: Re: [perl #130050] placement of use statement
To: perl6-compiler [...] perl.org
Date: Tue, 8 Nov 2016 20:48:06 +0100
Download (untitled) / with headers
text/plain 979b
Hi Will, It is the MongoDB distribution in the file t/Test-support.pm6. It starts with; use v6.c; use MongoDB::Client; use MongoDB::Collection; use MongoDB::Server::Control; and throws an error at line 119; 119: method get-connection ( Int :$server = 1 --> MongoDB::Client ) { $server = 1 unless $server ~~ any $!server-range; my Int $port-number = $!server-control.get-port-number("s$server"); MongoDB::Client.new(:uri("mongodb://localhost:$port-number")); } Changing the top into; use v6.c; use MongoDB::Collection; use MongoDB::Server::Control; use MongoDB::Client; clears the error. There are many modules involved so it is difficult to golf it to a simpler form. The code can be found at https://github.com/MARTIMM/mongo-perl6-driver. You have to look into the 'develop' branch for the files. The problem file(Test-support) is in the attachment together with the 3 modules and the test file using the Test-support. Regards, Marcel
Download Test-support.pm6
application/x-pagemaker 6.6k

Message body not shown because it is not plain text.

Download Client.pm6
application/x-pagemaker 17.2k

Message body not shown because it is not plain text.

Download Collection.pm6
application/x-pagemaker 19.4k

Message body not shown because it is not plain text.

Download Control.pm6
application/x-pagemaker 3.7k

Message body not shown because it is not plain text.

Download 110-Client.t
text/plain 2.7k

Message body is not shown because sender requested not to inline it.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org