develooper Front page | perl.perl5.porters | Postings from July 2001

caller() confused by & prototype

Thread Next
From:
Michael G Schwern
Date:
July 20, 2001 23:49
Subject:
caller() confused by & prototype
Message ID:
20010721024853.A13098@blackrider
caller() appears to be confused by the & prototype and reports the
line where the function call *ended* rather than where it starts.

    sub foo (&) {
        print "Caller is ".(caller)[2];
    }

    foo {
         42
    };

prints "Caller is 7"

compare that with:

    sub foo ($) {
        print "Caller is ".(caller)[2];
    }
    
    foo(  
        42
    );

prints "Caller is 5"


Smells like a bug.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
I'm not actually Kevin Lenzo, but I play him on TV.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About