Opened 10 years ago

Closed 10 years ago

#653 closed defect (fixed)

Lexically Rename Variable doesn't work when clicking on declaration of variable

Reported by: waxhead Owned by: patrickas
Priority: major Milestone:
Component: editor Version: 0.50
Keywords: Cc:


In the example code, taken straight from tsee's blog about refarctoring in padre:


sub _derive_atan2 {

my ( $tree, $var, $cloned, $d_sub ) = @_;
# d/df atan(y/x) = x2/(x2+y2) * (d/df y/x)
my ($op1, $op2) = @{$tree->{operands}};
my $inner = $d_sub->( $op1->new()/$op2->new(), $var, 0 );
# templates
my $two = Math::Symbolic::Constant->new(2);
my $op = Math::Symbolic::Operator->new('+', $two, $two);

my $result = $op->new('*',


$op->new('', $op2->new(), $two->new()),

'+', $op->new('', $op2->new(), $two->new()),
', $op1->new(), $two->new())



return $result;


To see the problem, on the line:

my ($op1, $op2) = @{$tree->{operands}};

click on either $op1 or $op2 and try to Lexically Rename them.

You get an error:

No declaration could be found for the specified (lexical?) variable

You can get this to work by selecting any other occurance of the variable name in the code block.

But this isn't what you'd expect.

Attachments (1)

653.patch (582 bytes) - added by patrickas 10 years ago.
file :

Download all attachments as: .zip

Change History (6)

comment:1 Changed 10 years ago by waxhead

  • Owner set to azawawi
  • Status changed from new to assigned

comment:2 Changed 10 years ago by patrickas

  • Owner changed from azawawi to patrickas
  • Status changed from assigned to accepted
  • Version changed from 0.47 to 0.50

The patch attached should fix the issue.

However, I noticed there were two declarations for the sub find_variable_declaration in

and in

The two subs are slightly different and this change makes them even more different.

I have no idea if they should be the same or if they are different on purpose.

comment:3 Changed 10 years ago by patrickas

Smaller test case:

my ($foo , $bar);

Place the cursor over $bar and select "Find variable declaration"

comment:4 Changed 10 years ago by Sewi

Fixed in r9181

comment:5 Changed 10 years ago by patrickas

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.