sub capture_list {
my $pad_capture = \&Eval::WithLexicals::Cage::pad_capture;
- my @names = grep $_ ne '&', map $_->PV, grep $_->isa('B::PV'),
+ my @names = grep defined && $_ ne '&', map $_->PV, grep $_->can('PV'),
svref_2object($pad_capture)->OUTSIDE->PADLIST->ARRAYelt(0)->ARRAY;
$Eval::WithLexicals::current_code .=
'+{ '.join(', ', map "'$_' => \\$_", @names).' };'