Subject: | Segfault if used in a one liner. |
The attached test demonstrates that Devel::Declare segfaults when used
in a one liner (or when the program is coming from STDIN). It
demonstrates some sort of memory or string corruption.
Subject: | oneliner.t |
#!/usr/bin/perl -w
use Test::More tests => 2;
ok open my $mod, '>', "Foo.pm";
print $mod <<'END';
package Foo;
use Devel::Declare;
BEGIN {
Devel::Declare->install_declarator(
"Foo", "method", DECLARE_PACKAGE | DECLARE_PROTO,
sub {
return q[my $self = shift;];
},
sub {
my ($name, $proto, $sub, @rest) = @_;
if (defined $name && length $name) {
unless ($name =~ /::/) {
$name = "Foo::${name}";
}
no strict "refs";
*{$name} = $sub;
}
return wantarray ? ($sub, @rest) : $sub;
}
);
}
1;
END
my $prog = <<'END';
package Foo;
method foo () {};
END
is system("$^X -I. -MFoo -wle '$prog'"), 0;
END {
unlink 'Foo.pm';
}