Skip Menu |

This queue is for tickets about the Scalar-Does CPAN distribution.

Report information
The Basics
Id: 81622
Status: resolved
Priority: 0/
Queue: Scalar-Does

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

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



Subject: MooseTypes / ClassName is incorrect in perl 5.17
In perl 5.17, type "ClassName" in MooseTypes will return always true. This is because the meaning of UNIVERSAL::can($scalar, 'can') has changed (see https://rt.perl.org/rt3/Public/Bug/Display.html?id=47113). I found this because I had a similar problem in Data::Domain and wanted to see how others solved it. Moose's solution goes through Class::Load::is_class_loaded, which is true if the package has a $VERSION, or has an @ISA, or has at least one method. It makes sense, but doesn't allow for an empty class. Another way (this is what I chose for Data::Domain) is to test for $scalar->isa($scalar) : this will be true if $scalar is a package, false otherwise (and this behaviour is kept consistent in 5.17).
Thanks. Strangely, to test if Foo::Bar is loaded, this seems to work quite well (from very limited testing): exists((\%Foo::Bar::)->{BEGIN})
Subject: Re: [rt.cpan.org #81622] MooseTypes / ClassName is incorrect in perl 5.17
Date: Sun, 02 Dec 2012 21:09:32 +0100
To: bug-Scalar-Does [...] rt.cpan.org
From: laurent dami <laurent.dami [...] free.fr>
Le 02.12.2012 20:43, Toby Inkster via RT a écrit : Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=81622 > > > Thanks. Strangely, to test if Foo::Bar is loaded, this seems to work > quite well (from very limited testing): > > exists((\%Foo::Bar::)->{BEGIN}) > > >
aha ... not a bad idea ! I just blogged about this issue in http://ldami.blogspot.ch/2012/12/how-to-test-if-something-is-perl-class.html , we'll see if people come up with other ideas.
Fixed in 0.010.