Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 100724
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: rrwo [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Moose::Exporter synopsis just doesn't work
Date: Fri, 05 Dec 2014 17:35:22 +0000
To: bug-Moose [...] rt.cpan.org
From: Robert Rothenberg <rrwo [...] cpan.org>
I've tried using Moose::Exporter to add some syntactic sugar, but the documentation does not help. Adapting examples from the SYNOPSIS, eliminating the obvious missing examples: Show quoted text
> package MyApp::Moose; > > use Moose (); > use Moose::Exporter; > > Moose::Exporter->setup_import_methods( > with_meta => [ 'has_rw' ], > also => 'Moose', > ); > > sub has_rw { > my ( $meta, $name, %options ) = @_; > $meta->add_attribute( > $name, > is => 'rw', > %options, > ); > } > > 1;
and Show quoted text
> package MyApp::User; > > use MyApp::Moose; > > has 'name'; > has_rw 'size'; > thing; > > no MyApp::Moose; > > 1;
Then running (on Perl 5.20.1): perl -I lib/ -MMyApp::User gives me the error: Show quoted text
> Bareword "thing" not allowed while "strict subs" in use at > lib/MyApp/User.pm line 7. > Compilation failed in require. > BEGIN failed--compilation aborted.
On 2014-12-05 09:35:34, RRWO wrote: ... Show quoted text
> > package MyApp::User; > > > > use MyApp::Moose; > > > > has 'name'; > > has_rw 'size'; > > thing; > > > > no MyApp::Moose; > > > > 1;
> > Then running (on Perl 5.20.1): > > perl -I lib/ -MMyApp::User > > gives me the error: >
> > Bareword "thing" not allowed while "strict subs" in use at > > lib/MyApp/User.pm line 7. > > Compilation failed in require. > > BEGIN failed--compilation aborted.
The "thing;" sub call is supposed to go with the import of \&Some::Random::thing, which you removed from the original example, so there's no error here. I do see a different error in the synopsis, introduced when we extended the syntax to accept bare subrefs, so thanks for bringing this up.
Subject: Re: [rt.cpan.org #100724] Moose::Exporter synopsis just doesn't work
Date: Mon, 8 Dec 2014 09:17:36 +0000
To: bug-Moose [...] rt.cpan.org
From: Robert Rothenberg <rrwo [...] cpan.org>
Removing the call for the "thing" sub, and we still get the error: Show quoted text
> String found where operator expected at lib/MyApp/User.pm line 7, near
"has_rw 'size'" (Do you need to predeclare has_rw?) syntax error at lib/MyApp/User.pm line 7, near "has_rw 'size'" BEGIN not safe after errors--compilation aborted at lib/MyApp/User.pm line 10. Compilation failed in require. BEGIN failed--compilation aborted. On Fri, Dec 5, 2014 at 5:51 PM, Karen Etheridge via RT < bug-Moose@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=100724 > > > On 2014-12-05 09:35:34, RRWO wrote: > ... >
> > > package MyApp::User; > > > > > > use MyApp::Moose; > > > > > > has 'name'; > > > has_rw 'size'; > > > thing; > > > > > > no MyApp::Moose; > > > > > > 1;
> > > > Then running (on Perl 5.20.1): > > > > perl -I lib/ -MMyApp::User > > > > gives me the error: > >
> > > Bareword "thing" not allowed while "strict subs" in use at > > > lib/MyApp/User.pm line 7. > > > Compilation failed in require. > > > BEGIN failed--compilation aborted.
> > The "thing;" sub call is supposed to go with the import of > \&Some::Random::thing, which you removed from the original example, so > there's no error here. > > I do see a different error in the synopsis, introduced when we extended > the syntax to accept bare subrefs, so thanks for bringing this up. > >
On 2014-12-08 01:17:45, RRWO wrote: Show quoted text
> Removing the call for the "thing" sub, and we still get the error: >
> > String found where operator expected at lib/MyApp/User.pm line 7, near
> "has_rw 'size'" > (Do you need to predeclare has_rw?) > syntax error at lib/MyApp/User.pm line 7, near "has_rw 'size'" > BEGIN not safe after errors--compilation aborted at lib/MyApp/User.pm line > 10. > Compilation failed in require. > BEGIN failed--compilation aborted.
Sorry, I can't reproduce. You'll have to paste the (full) code you're using.