Subject: | Strange MooseX::Declare behaivior |
Date: | Thu, 19 Jan 2012 11:56:54 +0400 |
To: | bug-MooseX-Declare [...] rt.cpan.org |
From: | Sergey Potapov <sp [...] smartspb.net> |
Hello!
Summary of strange things (perl 5.14.2 installed with perlbrew,
latest or almost latest Moose and MooseX::Declare installed using
cpanm):
sp@uskr:~/w$ cat strange_moosex_declare.pl
use MooseX::Declare;
class nom2 # Cannot find method 'm2'
{
method m1
{
1
}
method m2
{
2
}
}
class nom3 # Cannot find method 'm3'
{
method m1
{
1
}
method m2
{
2
}
method m3
{
3
}
}
class okm2 # All methods ok
{
method m1 {
1
}
method m2 {
2
}
}
class okm3 # All methods ok
{
method m1 {
1
}
method m2 {
2
}
method m3 {
3
}
}
my $nom2 = nom2->new;
my $nom3 = nom3->new;
my $okm2 = okm2->new;
my $okm3 = okm3->new;
print "\nStrange classes\n\n";
eval {
print "nom2->m1 returns ", $nom2->m1, "\n";
} or do {
print "nom2->m1 failed: ", $@;
};
eval {
print "nom2->m2 returns ", $nom2->m2, "\n";
} or do {
print "nom2->m2 failed: ", $@;
};
eval {
print "nom3->m1 returns ", $nom3->m1, "\n";
} or do {
print "nom3->m1 failed: ", $@;
};
eval {
print "nom3->m2 returns ", $nom3->m2, "\n";
} or do {
print "nom3->m2 failed: ", $@;
};
eval {
print "nom3->m3 returns ", $nom3->m3, "\n";
} or do {
print "nom3->m3 failed: ", $@;
};
print "\nOk classes\n\n";
eval {
print "okm2->m1 returns ", $okm2->m1, "\n";
} or do {
print "okm2->m1 failed: ", $@;
};
eval {
print "okm2->m2 returns ", $okm2->m2, "\n";
} or do {
print "okm2->m2 failed: ", $@;
};
eval {
print "okm3->m1 returns ", $okm3->m1, "\n";
} or do {
print "okm3->m1 failed: ", $@;
};
eval {
print "okm3->m2 returns ", $okm3->m2, "\n";
} or do {
print "okm3->m2 failed: ", $@;
};
eval {
print "okm3->m3 returns ", $okm3->m3, "\n";
} or do {
print "okm3->m3 failed: ", $@;
};
print "\nVersions:\n\n";
print " Moose ", Moose->VERSION, "\n";
print " MooseX::Declare ", MooseX::Declare->VERSION, "\n";
print " Perl\n", `perl -V`;
1;
__END__
# perl -w strange_moosex_declare.pl >> strange_moosex_declare.pl
Strange classes
nom2->m1 returns 1
nom2->m2 failed: Can't locate object method "m2" via package "nom2" at strange_moosex_declare.pl line 64.
nom3->m1 returns 1
nom3->m2 returns 2
nom3->m3 failed: Can't locate object method "m3" via package "nom3" at strange_moosex_declare.pl line 79.
Ok classes
okm2->m1 returns 1
okm2->m2 returns 2
okm3->m1 returns 1
okm3->m2 returns 2
okm3->m3 returns 3
Versions:
Moose 2.0401
MooseX::Declare 0.35
Perl
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux
uname='linux uskr 2.6.32-5-amd64 #1 smp thu nov 3 03:41:26 utc 2011 x86_64 gnulinux '
config_args='-de -Dprefix=/home/sp/perl5/perlbrew/perls/perl-5.14.2'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.4.5', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /lib64 /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
Built under linux
Compiled at Dec 19 2011 16:11:12
%ENV:
PERLBREW_BASHRC_VERSION="0.36"
PERLBREW_HOME="/home/sp/.perlbrew"
PERLBREW_MANPATH="/home/sp/perl5/perlbrew/perls/perl-5.14.2/man"
PERLBREW_PATH="/home/sp/perl5/perlbrew/bin:/home/sp/perl5/perlbrew/perls/perl-5.14.2/bin"
PERLBREW_PERL="perl-5.14.2"
PERLBREW_ROOT="/home/sp/perl5/perlbrew"
PERLBREW_VERSION="0.36"
@INC:
/home/sp/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux
/home/sp/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2
/home/sp/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux
/home/sp/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2
.
sp@uskr:~/w$
# --- begin perl ---
use MooseX::Declare;
# This works
class foo
{
method foo_first {
}
...
method foo_last_but_one {
}
method foo_last
}
# This cannot find method bar_last
class bar
{
method bar_first
{
}
...
method bar_last_but_one
{
}
method bar_last
{
}
}
# --- end perl ---
Complete example script with output: