Skip Menu |

This queue is for tickets about the Method-Signatures-Simple CPAN distribution.

Report information
The Basics
Id: 80510
Status: resolved
Priority: 0/
Queue: Method-Signatures-Simple

People
Owner: Nobody in particular
Requestors: MAUKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.02
Fixed in: (no value)



Subject: empty subroutines return bogus values
Seemingly empty subroutines return phantom values: $ cat bug/empty-body2 #!perl use Method::Signatures::Simple; func empty($x, $y) {} print scalar empty("A", "B"), "\n"; __END__ $ perl bug/empty-body2 2 $ cat bug/empty-body #!perl use Method::Signatures::Simple; method empty() {} print "$_\n" for __PACKAGE__->empty; __END__ $ perl bug/empty-body main
On Tue Oct 30 19:11:38 2012, MAUKE wrote: Show quoted text
> Seemingly empty subroutines return phantom values: > > $ cat bug/empty-body2 > #!perl > use Method::Signatures::Simple; > func empty($x, $y) {} > print scalar empty("A", "B"), "\n"; > __END__ > $ perl bug/empty-body2 > 2 > $ cat bug/empty-body > #!perl > use Method::Signatures::Simple; > method empty() {} > print "$_\n" for __PACKAGE__->empty; > __END__ > $ perl bug/empty-body > main
This is due to the fact that the signature is injected into the body, in the form of this line: my ($x, $y) = @_; Perl will then return the last evaluated expression, which is @_. So you can't really have empty funcs or methods. rhesa
On Fri Jan 18 06:55:47 2013, RHESA wrote: Show quoted text
> This is due to the fact that the signature is injected into the body, in > the form of this line: > > my ($x, $y) = @_; > > Perl will then return the last evaluated expression, which is @_. > So you can't really have empty funcs or methods.
Why not inject 'my ($x, $y) = @_; ();' instead?
Subject: Re: [rt.cpan.org #80510] empty subroutines return bogus values
Date: Fri, 18 Jan 2013 17:09:18 +0100
To: bug-Method-Signatures-Simple [...] rt.cpan.org
From: Rhesa Rozendaal <rhesa [...] cpan.org>
On 01/18/2013 05:04 PM, Lukas Mai via RT wrote: Show quoted text
> Queue: Method-Signatures-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=80510 > > > On Fri Jan 18 06:55:47 2013, RHESA wrote:
>> This is due to the fact that the signature is injected into the body, in >> the form of this line: >> >> my ($x, $y) = @_; >> >> Perl will then return the last evaluated expression, which is @_. >> So you can't really have empty funcs or methods.
> > Why not inject 'my ($x, $y) = @_; ();' instead?
Oh, I guess that'd work. Clever idea :) So why do you need empty methods and functions to begin with? rhesa
On Fri Jan 18 11:09:31 2013, RHESA wrote: Show quoted text
> On 01/18/2013 05:04 PM, Lukas Mai via RT wrote:
> > Queue: Method-Signatures-Simple > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=80510 > > > > > On Fri Jan 18 06:55:47 2013, RHESA wrote:
> >> This is due to the fact that the signature is injected into the
body, in Show quoted text
> >> the form of this line: > >> > >> my ($x, $y) = @_; > >> > >> Perl will then return the last evaluated expression, which is @_. > >> So you can't really have empty funcs or methods.
> > > > Why not inject 'my ($x, $y) = @_; ();' instead?
> > Oh, I guess that'd work. Clever idea :)
I just released this as 1.07. Thanks again!