Subject: | Useless use of private variable in void context when checking syntax |
Hello there,
These errors are always raised when I try to use Vim + perl-support + Perlbrew when editing scripts with Moose:
/home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm|677| Useless use of private variable in void context
/home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm|683| Useless use of private variable in void context
/home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm|704| Useless use of private variable in void context
Even though the code in TypeConstraings.pm is explicit disabling the warning:
sub _parse_parameterized_type_constraint {
{ no warnings 'void'; $any; } # force capture of interpolated lexical
$_[0] =~ m{ $type_capture_parts }x;
return ( $1, $2 );
}
Checking the syntax from the shell still shows an even more strange error:
[foobar@localhost ~]$ perl -cw /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm
The 'add_attribute' method cannot be called on an immutable instance at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Exception.pm line 37
Moose::Exception::_build_trace('Moose::Exception::CallingMethodOnAnImmutableInstance=HASH(0x2886e78)') called at reader Moose::Exception::trace (defined at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Exception.pm line 9) line 7
Moose::Exception::trace('Moose::Exception::CallingMethodOnAnImmutableInstance=HASH(0x2886e78)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Exception.pm line 49
Moose::Exception::BUILD('Moose::Exception::CallingMethodOnAnImmutableInstance=HASH(0x2886e78)', 'HASH(0x2886c20)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Method.pm line 126
Class::MOP::Method::execute('Moose::Meta::Method=HASH(0x2b42920)', 'Moose::Exception::CallingMethodOnAnImmutableInstance=HASH(0x2886e78)', 'HASH(0x2886c20)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Object.pm line 55
Moose::Object::BUILDALL('Moose::Exception::CallingMethodOnAnImmutableInstance=HASH(0x2886e78)', 'HASH(0x2886c20)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Meta/Class.pm line 281
Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x2a01cb0)', 'HASH(0x2886c20)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Object.pm line 26
Moose::Object::new('Moose::Exception::CallingMethodOnAnImmutableInstance', 'method_name', 'add_attribute') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Class/Immutable/Trait.pm line 94
Class::MOP::Class::Immutable::Trait::__throw_exception('CallingMethodOnAnImmutableInstance', 'method_name', 'add_attribute') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Class/Immutable/Trait.pm line 28
Class::MOP::Class::Immutable::Trait::_immutable_cannot_call('add_attribute') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Class/Immutable/Trait.pm line 43
Class::MOP::Class:::around('CODE(0x22acf70)', 'Class::MOP::Class::Immutable::Class::MOP::Class=HASH(0x25a2f78)', 'type_constraints', 'accessor', 'type_constraints', 'default', 'CODE(0x25a3500)', 'definition_context', 'HASH(0x28705e8)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Method/Wrapped.pm line 160
Class::MOP::Method::Wrapped::__ANON__('Class::MOP::Class::Immutable::Class::MOP::Class=HASH(0x25a2f78)', 'type_constraints', 'accessor', 'type_constraints', 'default', 'CODE(0x25a3500)', 'definition_context', 'HASH(0x28705e8)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP/Method/Wrapped.pm line 89
Class::MOP::Class::Immutable::Class::MOP::Class::add_attribute('Class::MOP::Class::Immutable::Class::MOP::Class=HASH(0x25a2f78)', 'type_constraints', 'accessor', 'type_constraints', 'default', 'CODE(0x25a3500)', 'definition_context', 'HASH(0x28705e8)') called at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Meta/TypeConstraint/Union.pm line 20
require Moose/Meta/TypeConstraint/Union.pm at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm line 28
Moose::Util::TypeConstraints::BEGIN at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Meta/TypeConstraint/Union.pm line 0
eval {...} at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Meta/TypeConstraint/Union.pm line 0
Compilation failed in require at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm line 28.
BEGIN failed--compilation aborted at /home/foobar/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Moose/Util/TypeConstraints.pm line 28.
While those errors don't cause any kind of trouble when running the program it has been impossible to properly check the syntax inside the editor. I didn't try to reproduce this error from a "vanilla" perl interpreter with Moose installed although.
I'm using the following versions:
[foobar@localhost ~]$ perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux
Copyright 1987-2012, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
[foobar@localhost ~]$ mversion Moose
2.1211