Update: Darn - it's back. Completely ignore the below meditation, instead to post a question!

This is a rehash of a stack-overflow answer I just made. I hope that's not against modern Perlmonks etiquette!

I recently got an odd error in some code that definitely worked before:

Can't upgrade BIND (1) to 9 at line 999

Google told me only that someone had seen the same error in a cgi once.

How I fixed it might be instructive although I'm still not exactly sure what it means. The code, that worked in some calling circumstances but not others, was a simple method forwarding method that looked a little like this:

sub quick_method { return shift->SUPER::some_other_method(@_); }

It's a little lazy, sure, but according to perl's left to right evaluation, it should (and usually was) the equivalent of this:

sub quick_method { my $self = shift; my @args = @_; return $self->SUPER::some_other_method(@args); }

I'm guessing that since @_ is, under some circumstances, a special way of accessing the stack and, under other circumstances, a fairly regular global list, the way in which the method was called was hitting different code paths.

Moral of the story - don't get too cute about modifying and using @_ in the same line of code!

Replies are listed 'Best First'.
Re: Don't get too cute about modifying and using @_ in the same line of code
by GlitchMr (Sexton) on Aug 23, 2012 at 08:53 UTC

    Doesn't happen for me with following code.

    use strict; use warnings; package Package1; use Data::Dumper; sub some_other_method { print Dumper @_; } package Package2; our @ISA = 'Package1'; sub some_other_method { die "Shouldn't be called!"; } sub quick_method { return shift->SUPER::some_other_method(@_); } sub new { bless {}, shift; } Package2->new->quick_method( 1, 2, 3 );

    It returns (correctly) following result (I've checked it in Perl v5.8.8, v5.10.1, v5.14.2, v5.16.1 and blead).

    $VAR1 = bless( {}, 'Package2' ); $VAR2 = 1; $VAR3 = 2; $VAR4 = 3;

    But, I think that so simple code won't show the bug - it happens in more complex cases (the warning you have got is internal Perl warning you should never see, but you saw according to perldiag - this is possibly a Perl bug). If you can, try to make testcase which shows the bug happening (by shortening the program to only have what you need to show bug). Also, there is chance that some XS module breaks something.