Skip Menu |

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

Report information
The Basics
Id: 63594
Status: open
Priority: 0/
Queue: MooseX-Method-Signatures

People
Owner: Nobody in particular
Requestors: j-zbiciak1 [...] ti.com
Cc:
AdminCc:

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



Subject: Newline between method and { causes strange behavior
Date: Sat, 4 Dec 2010 13:59:05 -0600
To: bug-MooseX-Method-Signatures [...] rt.cpan.org
From: Joe Zbiciak <j-zbiciak1 [...] ti.com>
Hello, In the attached example, if I put my opening curly brace for a 'method' on the same line as 'method' itself, everything works as expected. If I move the curly brace to the next line, it fails. What ends up happening is that MooseX::Method::Signatures appeares to pick up the signature for the *next* method, not the current method. Also, the last method in the package goes totally missing. The example 'signature_bug.pl' shows the misapplied method signatures. It results in the following output: $ ./signature_bug.pl Not busted: one_arg(not busted) Busted: Validation failed for 'Tuple[Tuple[Object,Any,Any],Dict[]]' with value [ [ busted=HASH(0x8f7152c), "busted" ], { } ], Internal Validation Error is: [+] Validation failed for 'Tuple[Object,Any,Any]' with value [ busted{ }, "busted" ] [+] Validation failed for 'Any' with value NULL at /db/perf/lib/perl5/site_perl/5.12.2/MooseX/Method/Signatures/Meta/Method.pm line 435 MooseX::Method::Signatures::Meta::Method::validate('MooseX::Method::Signatures::Meta::Method=HASH(0x8f71c34)', 'ARRAY(0x8f71928)') called at /db/perf/lib/perl5/site_perl/5.12.2/MooseX/Method/Signatures/Meta/Method.pm line 151 busted::one_arg('busted=HASH(0x8f7152c)', 'busted') called at ./signature_bug.pl line 14 The example 'signature_bug2.pl' shows how the final method in the module goes AWOL. It outputs the following: $ ./signature_bug2.pl Not busted: two_args(not, busted) Busted: Can't locate object method "two_args" via package "busted" at ./signature_bug2.pl line 14. Module version information: Perl 5.12.2 Moose 1.21 MooseX::Method::Signatures 0.36 Devel::Declare 0.006000 This is a fresh installation of Perl, Moose, etc. brought up to date with CPAN as of yesterday (03-Dec-2010). Regards, --Joe Zbiciak -- : Joseph Zbiciak, SMTS : Discovery consists of seeing : j-zbiciak1@ti.com : what everybody has seen and : #include <std_disc.h> : thinking what nobody has thought. : Texas Instruments : --Albert Szent-Gyorgyi
Download busted_on_newlines.zip
application/zip 1k

Message body not shown because it is not plain text.

From: Joe Zbiciak
I decided to dig about in the source code. (Shock! Horror!) I think I spotted the error in the logic, but I don't think I'm qualified to fix it. Here's where I think the thinko is: The _parser function sets up its code injector after all of the method arguments and other sugar are parsed. The body of the code injector sits in a "on_scope_end" hook. I'm willing to wager that the reason the code works with the curly brace on the same line as the last thing 'method' parsed is that Perl's parser has already entered the scope of the method's body. The reason it fails when the curly is on the next line is that it hasn't yet entered that scope. So, the code gets injected in the wrong place. I'm no expert in perl internals, but I think this is where the weirdness comes from. It could also explain the rather similar bug 61070--ie. they're really the same bug. I'll leave it to the experts to figure out the correct fix.
From: alain [...] rent.com
Joe, this is a duplicate of the following bug which has been open for quite a while now, and deemed "critical:" https://rt.cpan.org/Public/Bug/Display.html?id=61070 It only happens with perl 5.12.x. The only workaround right now is to simply use braces on the next line, or downgrade perl to 5.10.x.
From: alain [...] rent.com
On Wed Feb 02 21:13:59 2011, aavakian wrote: Show quoted text
> The only workaround right now is to > simply use braces on the next line, or downgrade perl to 5.10.x.
and of course, I meant for the workaround to use braces on the *same* line.
Subject: Re: [rt.cpan.org #63594] Newline between method and { causes strange behavior
Date: Thu, 3 Feb 2011 00:39:45 -0600
To: Alain Avakian via RT <bug-MooseX-Method-Signatures [...] rt.cpan.org>
From: Joe Zbiciak <j-zbiciak1 [...] ti.com>
Alain, I wasn't 100% certain I was hitting the same bug, since my symptoms weren't exactly the same. If I knew more about perl internals, I might attempt a fix. For now, I am going to stick with Perl 5.12, move my brace to the same line as method where needed, and apply MooseX::Method::Signatures sparingly in new code. Thanks, --Joe -- : Joseph Zbiciak, SMTS : "I am always doing what I : j-zbiciak1@ti.com : cannot do yet, in order to : #include <std_disc.h> : learn how to do it." : Texas Instruments : -- Vincent van Gogh
Does this issue still exist? Recent releases to Devel::Declare appear to address similar reported issues (e.g. https://rt.cpan.org/Ticket/Display.html?id=71528).