Bug#98430: perl: Can't C<goto &func> at end of lvalue sub
Dominic Hargreaves
dom at earth.li
Thu Jun 2 21:12:16 UTC 2011
found 98430 5.14.0-1
notforwarded 98430
thanks
On Thu, May 24, 2001 at 05:28:38PM +1000, Brendan O'Dea wrote:
> [Full bug report details are at http://bugs.debian.org/98430. Please
> retain 98430-forwarded at bugs.debian.org in the Cc field of replies.]
>
> Summary: A module which worked with 5.6.0 now chokes under 5.6.1 with a
> compile-time error on goto& from an lvalued subroutine.
>
> Here's a small example program:
>
> package Bug;
> $value = 'none';
> sub a :lvalue { $value }
> sub b :lvalue { goto &a }
> sub AUTOLOAD :lvalue { goto &a }
> b() = 'sub' if grep /^sub/, @ARGV;
> c() = 'auto-sub' if grep /^auto-sub/, @ARGV;
> Bug->b() = 'method' if grep /^method/, @ARGV;
> Bug->d() = 'auto-method' if grep /^auto-method/, @ARGV;
> print "$value\n";
>
> Note that if the AUTOLOAD in this example instead contains
>
> *$AUTOLOAD = sub :lvalue { $value };
> goto &$AUTOLOAD;
>
> which is closer to the code described in the bug report, the behaviour
> is unchanged. Under 5.6.0, the following occurs:
>
> $ perl -w bug
> none
> $ perl -w bug sub
> sub
> $ perl -w bug auto-sub
> Can't modify non-lvalue subroutine call at bug line 7.
> $ perl -w bug method
> method
> $ perl -w bug auto-method
> auto-method
>
> So there's only one case which doesn't work, where a non-method AUTOLOAD
> is called and the exception occurs at run-time.
>
> The code doesn't compile under 5.6.1:
>
> $ perl -w bug
> Can't modify goto in lvalue subroutine return at bug line 4, near "&a }"
> BEGIN not safe after errors--compilation aborted at bug line 5.
>
> Basically any goto& within an :lvalue subroutine fails.
After 10 years, this test program still doesn't work. There was
no follow-up from p5p to this post. I'm inclined to think that this
was an unfortunat backwards-incompatible change made in 5.6.1, but that
it's quite unlikely to be changed now. Any objections to be me closing
this?
--
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)
More information about the Perl-maintainers
mailing list