Skip Menu |

This queue is for tickets about the Devel-REPL CPAN distribution.

Report information
The Basics
Id: 43151
Status: resolved
Priority: 0/
Queue: Devel-REPL

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

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



Subject: tab completion plugin doesn't work with _
Pressing tab after "_->" results in "Error! - I do not recognize that sigil '_' at /usr/lib/perl5/site_perl/5.10.0/Class/MOP/Package.pm line 116"
On Mon Feb 09 12:50:53 2009, DOY wrote: Show quoted text
> Pressing tab after "_->" results in "Error! - I do not recognize that > sigil '_' at /usr/lib/perl5/site_perl/5.10.0/Class/MOP/Package.pm line
116" I'm not sure how you would like to have it complete things here. However, I think the fact that it reports an error after a valid construct could be construed as a bug and not a "feature".
The problem report appears incomplete. I guess the user may be trying TAB completion from the _ routine in the OutputCache plugin. It is unclear what completion is desired, available, or useful, but ideally the complete should not generate an error from valid code. On Mon Feb 09 12:50:53 2009, DOY wrote: Show quoted text
> Pressing tab after "_->" results in "Error! - I do not recognize that > sigil '_' at /usr/lib/perl5/site_perl/5.10.0/Class/MOP/Package.pm line
116"
The problem occurs in CompletionDriver::Methods around line 43. find_variable is being called with '_' which is incorrect since '_' is not a variable (has no sigil). The fix would be to do a little better check here....
This fixes the error from TAB completion of the _-> construct. I'm not sure what completions would happen from that initial step but the completion does not die trying now. Fixed in git and should be in the next release. I've attached the new version of the FindVariable plugin in the meantime.
Subject: FindVariable.pm
package Devel::REPL::Plugin::FindVariable; use Devel::REPL::Plugin; use namespace::clean -except => [ 'meta' ]; sub find_variable { my ($self, $name) = @_; return \$self if $name eq '$_REPL'; # XXX: this code needs to live in LexEnv if ($self->can('lexical_environment')) { return \( $self->lexical_environment->get_context('_')->{$name} ) if exists $self->lexical_environment->get_context('_')->{$name}; } my $sigil = $name =~ s/^([\$\@\%\&\*])// ? $1 : ''; my $default_package = $self->can('current_package') ? $self->current_package : 'main'; my $package = $name =~ s/^(.*)(::|')// ? $1 : $default_package; my $meta = Class::MOP::Class->initialize($package); # Class::MOP::Package::has_package_symbol method *requires* a sigil return unless length($sigil) and $meta->has_package_symbol("$sigil$name"); $meta->get_package_symbol("$sigil$name"); } 1; __END__ =head1 NAME Devel::REPL::Plugin::FindVariable - Finds variables by name =head1 AUTHOR Shawn M Moore, C<< <sartak at gmail dot com> >> =cut