Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 47358
Status: open
Priority: 0/
Queue: Perl-Critic

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

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



Subject: BuiltinFunctions::ProhibitVoidMap is confusable about context, apparently.
This code passes: my $hashref = { map { $_ => 1 } $source->_get_files_array() }; $self->_set_files_hashref( $hashref ); [From File::List::Object 0.189] This code - the logical equivalent - does not: $self->_set_files_hashref( { map { $_ => 1 } $source->_get_files_array() } ); (Explanation of the weird code is that $source->_get_files_array is getting the keys of the internal hashref from the $source object, which happen to be filenames. The "map" maps each filename to a two value list, the filename and 1. The list returned from the map is made into a hashref by the outer set of brackets, which is set into the internal hashref of the destination object ($self) via $self->_set_files_hashref. So the "map" is in list context, as far as I can tell, [because of the hashref conversion] as opposed to the void context that the policy is supposed to complain about.)
CC: bug-PPI [...] rt.cpan.org
Subject: Re: [rt.cpan.org #47358] BuiltinFunctions::ProhibitVoidMap is confusable about context, apparently.
Date: Fri, 26 Jun 2009 09:14:28 -0400
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Curtis Jewell via RT wrote: Show quoted text
> This code passes: > my $hashref = { map { $_ => 1 } $source->_get_files_array() }; > $self->_set_files_hashref( $hashref ); > > [From File::List::Object 0.189] > This code - the logical equivalent - does not: > $self->_set_files_hashref( { map { $_ => 1 } > $source->_get_files_array() } );
This is a PPI bug. Note how the outer curly braces get classified as a block and not a hash constructor: PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$self' [ 1, 6, 6 ] PPI::Token::Operator '->' [ 1, 8, 8 ] PPI::Token::Word '_set_files_hashref' PPI::Structure::List ( ... ) PPI::Statement::Compound PPI::Structure::Block { ... } PPI::Statement [ 1, 30, 30 ] PPI::Token::Word 'map' PPI::Structure::Block { ... } PPI::Statement [ 1, 36, 36 ] PPI::Token::Magic '$_' [ 1, 39, 39 ] PPI::Token::Operator '=>' [ 1, 42, 42 ] PPI::Token::Number '1' [ 1, 46, 46 ] PPI::Token::Symbol '$source' [ 1, 53, 53 ] PPI::Token::Operator '->' [ 1, 55, 55 ] PPI::Token::Word '_get_files_array' PPI::Structure::List ( ... ) [ 1, 77, 77 ] PPI::Token::Structure ';'
CC: bug-PPI [...] rt.cpan.org
Subject: Re: [rt.cpan.org #47358] BuiltinFunctions::ProhibitVoidMap is confusable about context, apparently.
Date: Fri, 26 Jun 2009 09:14:28 -0400
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Curtis Jewell via RT wrote: Show quoted text
> This code passes: > my $hashref = { map { $_ => 1 } $source->_get_files_array() }; > $self->_set_files_hashref( $hashref ); > > [From File::List::Object 0.189] > This code - the logical equivalent - does not: > $self->_set_files_hashref( { map { $_ => 1 } > $source->_get_files_array() } );
This is a PPI bug. Note how the outer curly braces get classified as a block and not a hash constructor: PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$self' [ 1, 6, 6 ] PPI::Token::Operator '->' [ 1, 8, 8 ] PPI::Token::Word '_set_files_hashref' PPI::Structure::List ( ... ) PPI::Statement::Compound PPI::Structure::Block { ... } PPI::Statement [ 1, 30, 30 ] PPI::Token::Word 'map' PPI::Structure::Block { ... } PPI::Statement [ 1, 36, 36 ] PPI::Token::Magic '$_' [ 1, 39, 39 ] PPI::Token::Operator '=>' [ 1, 42, 42 ] PPI::Token::Number '1' [ 1, 46, 46 ] PPI::Token::Symbol '$source' [ 1, 53, 53 ] PPI::Token::Operator '->' [ 1, 55, 55 ] PPI::Token::Word '_get_files_array' PPI::Structure::List ( ... ) [ 1, 77, 77 ] PPI::Token::Structure ';'