Skip Menu |

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 79170
Status: resolved
Priority: 0/
Queue: Module-Build

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

Bug Information
Severity: (no value)
Broken in: 0.4003
Fixed in: 0.4006



Subject: adding hash properties clobbers hash properties in base class
Attached is an example which demonstrates the problem. Using add_property to add a hash property clobbers the properties in the base class. This is the error I get: gato% perl -Ilib Build.PL --install_path lib=/util/lib/perl Can't use string ("lib=/util/lib/perl") as a HASH ref while "strict refs" in use at /home/ollisg/perl5/gato/lib/perl5/Module/Build/Base.pm line 2240.
Subject: Build.PL
#!/usr/bin/env perl package Module::Build::Foo; use strict; use warnings; use base qw( Module::Build ); __PACKAGE__->add_property( foo => { x => 1, y => 2 }); package main; my $builder = Module::Build::Foo->new( module_name => 'Foo', license => 'perl', build_requires => {}, ); 1;
Attached is a patch (including a simple test) to Module::Build which seems to solve the error for me. The existing test suite passes for me.
Subject: Module-Build.diff
diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index cf42cc0..d6b52e6 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -764,10 +764,7 @@ sub ACTION_config_data { } sub hash_properties { - for (shift->_mb_classes) { - return @{$additive_properties{$_}->{'HASH'}} - if exists $additive_properties{$_}->{'HASH'}; - } + map { exists $additive_properties{$_}->{HASH} ? @{$additive_properties{$_}->{HASH}} : () } shift->_mb_classes; } sub add_property { diff --git a/t/add_property_hash.t b/t/add_property_hash.t new file mode 100644 index 0000000..afd71f8 --- /dev/null +++ b/t/add_property_hash.t @@ -0,0 +1,16 @@ +#!/usr/bin/perl -w + +use strict; +use lib 't/lib'; +use MBTest tests => 1; + +blib_load 'Module::Build'; + +ADDPROP: { + package My::Build::Prop; + use base 'Module::Build'; + __PACKAGE__->add_property( 'hash_property' => {}); +} + +ok grep { $_ eq 'install_path' } My::Build::Prop->hash_properties, "has install_path even after adding another hash property"; +
fixed in 0.4006