Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Tidy-Sweetened CPAN distribution.

Report information
The Basics
Id: 106464
Status: resolved
Priority: 0/
Queue: Perl-Tidy-Sweetened

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

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



Subject: Breaks with anonymous subs in sub calls without parens
Using the 1.04 and the latest Perl::Tidy, tidying of: method _path => sub { $path }; fails with: expecting ':' or ';' or '{' after definition or declaration of sub '_path' but saw '=' Adding parens to method() stops the error from occurring. Greg
Greg, Can you give me some more color on where this would be used? I am aware of issues with anonymous subs, ie: my $x = { bar => func ($param) { say $param }, }; I would really like to get this working, but it doesn't really fit into the existing solution. I've got an open GitHub issue for it. I'm not certain where the syntax in your example would be used? Which package are you getting the method keyword from? How is that different from: method _path { $path } Thanks, Mark On Fri Aug 14 17:31:30 2015, OSCHWALD wrote: Show quoted text
> Using the 1.04 and the latest Perl::Tidy, tidying of: > > method _path => sub { $path }; > > fails with: > > expecting ':' or ';' or '{' after definition or declaration of sub > '_path' but saw '=' > > Adding parens to method() stops the error from occurring. > > Greg
Hi Mark, It would affect any sub called without parens that takes an anonymous subroutine as a parameter. However, this particular example hit our code using parameterized roles with Moose: https://metacpan.org/pod/MooseX::Role::Parameterized which provides the method sub to declare methods. Are you suggesting that the parameterized role module should use prototypes so that it can take code blocks without the `sub`? That seems possible, although not currently implemented in it, but ideally this module should run on most valid Perl and not require awkward workarounds or modifying of third party modules. Thanks! Greg On Mon Aug 17 11:20:26 2015, MGRIMES wrote: Show quoted text
> Greg, > > Can you give me some more color on where this would be used? I am > aware of issues with anonymous subs, ie: > > my $x = { > bar => func ($param) { say $param }, > }; > > I would really like to get this working, but it doesn't really fit > into the existing solution. I've got an open GitHub issue for it. > > I'm not certain where the syntax in your example would be used? Which > package are you getting the method keyword from? How is that different > from: > > method _path { $path } > > Thanks, > Mark > > > On Fri Aug 14 17:31:30 2015, OSCHWALD wrote:
> > Using the 1.04 and the latest Perl::Tidy, tidying of: > > > > method _path => sub { $path }; > > > > fails with: > > > > expecting ':' or ';' or '{' after definition or declaration of sub > > '_path' but saw '=' > > > > Adding parens to method() stops the error from occurring. > > > > Greg
I see. MooseX::Role::Parameterized provides a function named "method". Unlike the method (pseudo) keyword provided by Method::Signatures::Simple, MooseX::Method::Signatures, etc, this doesn't need any special processing. Perl::Tidy::Sweet should just ignore this. Unfortunately, that's easier said than done. A simple work around is to quote the hash key ("_path" in your example). On Mon Aug 17 12:14:08 2015, OSCHWALD wrote: Show quoted text
> Hi Mark, > > It would affect any sub called without parens that takes an anonymous > subroutine as a parameter. However, this particular example hit our > code using parameterized roles with Moose: > > https://metacpan.org/pod/MooseX::Role::Parameterized > > which provides the method sub to declare methods. > > Are you suggesting that the parameterized role module should use > prototypes so that it can take code blocks without the `sub`? That > seems possible, although not currently implemented in it, but ideally > this module should run on most valid Perl and not require awkward > workarounds or modifying of third party modules. > > Thanks! > > Greg > > On Mon Aug 17 11:20:26 2015, MGRIMES wrote:
> > Greg, > > > > Can you give me some more color on where this would be used? I am > > aware of issues with anonymous subs, ie: > > > > my $x = { > > bar => func ($param) { say $param }, > > }; > > > > I would really like to get this working, but it doesn't really fit > > into the existing solution. I've got an open GitHub issue for it. > > > > I'm not certain where the syntax in your example would be used? Which > > package are you getting the method keyword from? How is that > > different > > from: > > > > method _path { $path } > > > > Thanks, > > Mark > > > > > > On Fri Aug 14 17:31:30 2015, OSCHWALD wrote:
> > > Using the 1.04 and the latest Perl::Tidy, tidying of: > > > > > > method _path => sub { $path }; > > > > > > fails with: > > > > > > expecting ':' or ';' or '{' after definition or declaration of sub > > > '_path' but saw '=' > > > > > > Adding parens to method() stops the error from occurring. > > > > > > Greg
Fix was released as 1.07. Thanks for the report and patch.
On Wed Jan 27 18:08:16 2016, MGRIMES wrote: Show quoted text
> Fix was released as 1.07. Thanks for the report and patch.
Thanks!