Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Constants in 5.10 will sometimes show up as scalar refs in the symbol…
Browse files Browse the repository at this point in the history
… table.

Probably some optimization.  rt.cpan.org 40495
  • Loading branch information
schwern committed Jan 22, 2010
1 parent f558f73 commit 9d6d1a0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
0.07
Bug Fixes:
* Classes which defined constants did not work with mixin on
Perl 5.10.x. [rt.cpan.org 40495]

Interface:
- Slightly better error message when trying to use a mixin and you're
not of the right class.
Expand Down
2 changes: 1 addition & 1 deletion lib/mixin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ sub _thieve_public_methods {
while( my($sym, $glob) = each %{$mixin.'::'}) {
next if $sym =~ /^_/;
next unless defined $glob;
*glob = *$glob;
*glob = *{$mixin.'::'.$sym};
*{$pkg.'::'.$sym} = *glob{CODE} if *glob{CODE};
}

Expand Down
26 changes: 26 additions & 0 deletions t/constant.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/perl -w

# 5.10.0 changed the way constants are represented in the symbol table.

use strict;
use Test::More tests => 2;

{
package A;
use mixin::with 'Top';
use constant FOO => "Bar";
}

{
package Top;
sub new { bless {}, shift }
}

{
package MixinUser;
use base qw(Top);
use mixin qw(A);
}

pass("Mixins work with classes using constants");
is(MixinUser->new->FOO, "Bar", "Expected constant value");

0 comments on commit 9d6d1a0

Please sign in to comment.