Mailing List Archive

"Can't locate" can be non-trappable
To trigger this one requires a tied variable, whose FETCH calls a
failing "require", in a vector context.

It's possible to simplify this program slightly and preserve the bug,
but I wanted to make everything legal except for the failing 'require'.

package Foo;
sub TIEHASH { bless [] }
sub FETCH { require 'cause of problem'; 1 }

package main;
tie %t,Foo;
@x = ( 1, eval { $t{BANG} } );
print "Bug has been fixed!\n";

(I ran into this inadvertantly since my perl-shell always evaluates in
vector context. But, yes, I do want to have a FETCH method calling
"require". It's a sort of autoloader.)

Ian
Re: "Can't locate" can be non-trappable [ In reply to ]
Subject should be:

Exceptions in FETCH are sometimes not trappable through tied access.

Nick Ing-Simmons <nik@tiuk.ti.com> wrote:

> Presumably the work-round is to the eval {} in the FETCH ?

Nope. But checking this out narrows it down a bit further, and the
dependency on vectors appears to be spurious - I think the bug appears
if the containing 'eval {}' is in a non-void context:

package Foo;
sub TIEHASH { bless [] }
sub FETCH { die "We have a bug" }

package main;
tie %t,Foo;
eval { $x = $t{HELLO} };
print "Void is OK\n";
$x = eval { $t{HELLO} };
print "Scalars are OK\n";
@x = ( 1, eval { $t{BANG} } );
print "Vectors are OK\n";
print "Bug has been fixed!\n";

Ian