Skip Menu |

This queue is for tickets about the aliased CPAN distribution.

Report information
The Basics
Id: 103259
Status: rejected
Priority: 0/
Queue: aliased

People
Owner: ether [...] cpan.org
Requestors: karjala [...] karjala.org
Cc:
AdminCc:

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



Subject: Warning "Constant subroutine redefined" shouldn't appear
Here's the simplest way to reproduce the error. 3 files residing in the same directory: File check.pl: #!/usr/bin/perl use Alex; use aliased 'Charlie' => 'DB::Sandy'; File Alex.pm: package Alex; use aliased 'Charlie' => 'DB::Sandy'; 1; File Charlie.pm: package Charlie; 1; Try to execute check.pl. Silly warning appears. Warning doesn't appear if the alias does not contain ::
From: karjala [...] karjala.org
Using Perl version 5.18.2 on Ubuntu trusty. Tried it on two VMs with Ubuntu Server Trusty installed.
From: karjala [...] karjala.org
I believe that this bug did not occur on aliased 0.31 (because I never saw it when I was using it).
From: karjala [...] karjala.org
Here's the full text of the warning: Constant subroutine DB::Sandy redefined at /home/karjala/perl5/lib/perl5/aliased.pm line 45.
On 2015-04-01 15:37:21, KARJALA wrote: Show quoted text
> I believe that this bug did not occur on aliased 0.31 (because I never > saw it when I was using it).
hahahahaha... bisected to this commit: https://github.com/karenetheridge/aliased/commit/498aeaffe8447986de893d3dbb0f1767e2e8afb3 I'll look into this more tonight.
On 2015-04-01 16:09:01, ETHER wrote: Show quoted text
> On 2015-04-01 15:37:21, KARJALA wrote:
> > I believe that this bug did not occur on aliased 0.31 (because I > > never > > saw it when I was using it).
> > hahahahaha... bisected to this commit: > https://github.com/karenetheridge/aliased/commit/498aeaffe8447986de893d3dbb0f1767e2e8afb3 > > I'll look into this more tonight.
So, anyway, this warning is showing up now because we're now doing 'use warnings' in aliased.pm. You're getting the warning because you're adding something to the DB:: namespace, which I believe makes it readonly (although I don't know the deep guts mechanics here) and then doing it again, which overwrites the first constant sub. So there's multiple "don't do that"s here -- don't put things into a foreign namespace (as cautioned about in https://metacpan.org/pod/aliased#Explicit-Aliasing (see "Messing around with different namespaces is a really bad idea..."), especially don't put things into DB::, and then don't create the same alias twice from multiple locations. (You can disable this warning yourself, at any rate, with "no warnings 'redefine';".) I think it's reasonable to add a special warning when creating an alias in another namespace, so I've pencilled in a TODO item for that.