what is this i don't even
Jesse Luehrs [Wed, 12 May 2010 17:33:44 +0000 (12:33 -0500)]
lib/Stash/Manip.pm
t/005-isa.t [new file with mode: 0644]

index 173ba13..a9f4bfa 100644 (file)
@@ -205,7 +205,13 @@ sub get_package_symbol {
     my $namespace = $self->namespace;
 
     if (!exists $namespace->{$name}) {
-        if ($type eq 'ARRAY') {
+        # assigning to the result of this function like
+        #   @{$stash->get_package_symbol('@ISA')} = @new_ISA
+        # makes the result not visible until the variable is explicitly
+        # accessed... in the case of @ISA, this might never happen
+        # for instance, assigning like that and then calling $obj->isa
+        # will fail. see t/005-isa.t
+        if ($type eq 'ARRAY' && $name ne 'ISA') {
             $self->add_package_symbol($variable, []);
         }
         elsif ($type eq 'HASH') {
diff --git a/t/005-isa.t b/t/005-isa.t
new file mode 100644 (file)
index 0000000..d21c7a7
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Stash::Manip;
+
+{
+    package Foo;
+}
+
+{
+    package Bar;
+}
+
+my $stash = Stash::Manip->new('Foo');
+my @ISA = ('Bar');
+@{$stash->get_package_symbol('@ISA')} = @ISA;
+isa_ok('Foo', 'Bar');
+
+done_testing;