Skip Menu |

This queue is for tickets about the Role-Tiny CPAN distribution.

Report information
The Basics
Id: 83248
Status: resolved
Priority: 0/
Queue: Role-Tiny

People
Owner: Nobody in particular
Requestors: tokuhirom+cpan [...] gmail.com
Cc:
AdminCc:

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



Subject: Using Role::Tiny->apply_roles_to_object with too many roles makes too long package name
If using Role::Tiny->apply_roles_to_object with too many roles, it makes 'Identifier too long' error in string 'eval'. And, Moo uses string eval. I think Role::Tiny should shorten the package name if it's too long. Here is test result: # Foo__WITH__R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA__WITH__R::BBB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB__WITH__R::CCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCC__WITH__R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD DDDDDDDDDDD__WITH__R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE not ok 1 # Failed test at hoge.pl line 40. # Identifier too long at (eval 10) line 1. 1..1 # Looks like you failed 1 test of 1. Here is a test case: use strict; use warnings; use Test::More; # using Role::Tiny->apply_roles_to_object with too many roles, # It makes 'Identifier too long' error in string 'eval'. # And, Moo uses string eval. { package R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; use Role::Tiny; package R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB; use Role::Tiny; package R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC; use Role::Tiny; package R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD; use Role::Tiny; package R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE; use Role::Tiny; } { package Foo; sub new { bless {}, shift } } my $foo = Foo->new(); for (qw( R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE )) { Role::Tiny->apply_roles_to_object($foo, $_); } my $pkg = ref $foo; note $pkg; eval "package $pkg;"; ok(!$@) or diag $@; done_testing;
Subject: Re: [rt.cpan.org #83248] AutoReply: Using Role::Tiny->apply_roles_to_object with too many roles makes too long package name
Date: Sun, 10 Feb 2013 12:18:09 +0900
To: bug-Role-Tiny [...] rt.cpan.org
From: Tokuhiro Matsuno <tokuhirom [...] gmail.com>
Note: I found this issue when porting program using Moose to Moo. On Sun, Feb 10, 2013 at 12:12 PM, Bugs in Role-Tiny via RT < bug-Role-Tiny@rt.cpan.org> wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Using Role::Tiny->apply_roles_to_object with too many roles makes > too long package name", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #83248]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=83248 > > Please include the string: > > [rt.cpan.org #83248] > > in the subject line of all future correspondence about this issue. To do > so, > you may reply to this message. > > Thank you, > bug-Role-Tiny@rt.cpan.org > > ------------------------------------------------------------------------- > If using Role::Tiny->apply_roles_to_object with too many roles, > it makes 'Identifier too long' error in string 'eval'. > And, Moo uses string eval. > > I think Role::Tiny should shorten the package name if it's too long. > > Here is test result: > # > Foo__WITH__R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA__WITH__R::BBB > > BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB__WITH__R::CCCCCCCCCCCCCCCCCCCCCCCC > CCCCCCCCCCCCCCCCCCCCCC__WITH__R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD > DDDDDDDDDDD__WITH__R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE > not ok 1 > # Failed test at hoge.pl line 40. > # Identifier too long at (eval 10) line 1. > 1..1 > # Looks like you failed 1 test of 1. > > Here is a test case: > > use strict; > use warnings; > use Test::More; > > # using Role::Tiny->apply_roles_to_object with too many roles, > # It makes 'Identifier too long' error in string 'eval'. > # And, Moo uses string eval. > { > package R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; > use Role::Tiny; > package R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB; > use Role::Tiny; > package R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC; > use Role::Tiny; > package R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD; > use Role::Tiny; > package R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE; > use Role::Tiny; > } > > { > package Foo; > sub new { bless {}, shift } > } > > my $foo = Foo->new(); > for (qw( > R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA > R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB > R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC > R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD > R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE > )) { > Role::Tiny->apply_roles_to_object($foo, $_); > } > > my $pkg = ref $foo; > note $pkg; > eval "package $pkg;"; > ok(!$@) or diag $@; > > done_testing; > >
On Sat Feb 09 22:12:39 2013, TOKUHIROM wrote: Show quoted text
> I think Role::Tiny should shorten the package name if it's too long.
I would also suggest a bit more "inteligence" when constructing said name. Namely: - Replace '__WITH__' with '+' - it is short and just as informative (and a valid stash-name when used correctly) - Extract the common part such that Foo with Foo::Stuff with Foo::More::Stuff becomes Foo+::Stuff+::More::Stuff I am willing to do all the legwork in implementing/testing this as soon as I get a green light to do it.
On Fri Mar 29 10:34:03 2013, RIBASUSHI wrote: Show quoted text
> On Sat Feb 09 22:12:39 2013, TOKUHIROM wrote:
> > I think Role::Tiny should shorten the package name if it's too long.
> > I would also suggest a bit more "inteligence" when constructing said > name. Namely: > - Replace '__WITH__' with '+' - it is short and just as informative > (and a valid stash-name when used correctly) > - Extract the common part such that Foo with Foo::Stuff with > Foo::More::Stuff becomes Foo+::Stuff+::More::Stuff > > I am willing to do all the legwork in implementing/testing this as > soon as I get a green light to do it.
I like this idea, but fwiw we actually started with +. See commit c69190f1086805f314dbe3bc2926aa940abd4001. Maybe the code could have been better though?
Subject: Re: [rt.cpan.org #83248] Using Role::Tiny->apply_roles_to_object with too many roles makes too long package name
Date: Mon, 8 Apr 2013 00:54:03 +1000
To: Frew Schmidt via RT <bug-Role-Tiny [...] rt.cpan.org>
From: Peter Rabbitson <ribasushi [...] cpan.org>
On Sun, Apr 07, 2013 at 10:39:15AM -0400, Frew Schmidt via RT wrote: Show quoted text
> Queue: Role-Tiny > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=83248 > > > On Fri Mar 29 10:34:03 2013, RIBASUSHI wrote:
> > On Sat Feb 09 22:12:39 2013, TOKUHIROM wrote:
> > > I think Role::Tiny should shorten the package name if it's too long.
> > > > I would also suggest a bit more "inteligence" when constructing said > > name. Namely: > > - Replace '__WITH__' with '+' - it is short and just as informative > > (and a valid stash-name when used correctly) > > - Extract the common part such that Foo with Foo::Stuff with > > Foo::More::Stuff becomes Foo+::Stuff+::More::Stuff > > > > I am willing to do all the legwork in implementing/testing this as > > soon as I get a green light to do it.
> > I like this idea, but fwiw we actually started with +. See commit c69190f1086805f314dbe3bc2926aa940abd4001. Maybe the code could have been better though?
Good to know. Yes, defer_sub needs fixing, unrelated to any of the above. /me makes another note... QAH maybe... Sigh
I've created a fix for this that will automatically abbreviate the generated package names if they are too long in the long-package-name branch. It also moves the name generation into a sub, allowing subclasses (Moo) to use the routine directly instead of reimplementing it. Given that long names have until now been broken, there's no need to keep them compatible with the old generated names. If we wanted to generate 'smarter' shortened names for things that are currently working, backcompat would start to be an issue.
Fixed in 1.003002. The next Moo release will also include a fix for this.