You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function "Go to Definition" fails to identify the correct definition if a subroutine with the same name is present in another package in the same file, or if the subroutine is a lexical sub.
Here's a demo code:
use strict;
packagemain;
subshow { print"main::show\n"; }
packagePrivate {
mysubshow { print"lexical sub show in package Private\n"; }
subbarf {
# This calls the lexical subroutine in package Private
show(@_) # but find definition -> main::show
}
}
packageInner {
subshow { print"Inner::show\n" }
}
# This calls main::show
show; # but find definition -> Inner::show
This code has three subroutines called show: "public" subroutines in packages main and Inner, and a lexical subroutine in package Private. When I invoke "Go to Definition" from the places where show is called, it does not select the correct one.
It seems that lexical subroutines are not found at all, and the namespace is ignored for public subroutines.
The text was updated successfully, but these errors were encountered:
Thanks for the report. Lexical subroutines are certainly worth supporting and should be fairly straightforward.
Scoping is much harder and the Go To Definition doesn't currently attempt to resolve based on scope. It does have some understanding of scope that is visible in the nested outline view (image below). I suspect the Navigator needs PPI to build a stronger tree based understanding of the document, which would also help with #35
Currently, it will always Go To the next highest definition. This makes the most sense for $variables, as the prior definition is usually the correct one (e.g. multiple subs that re-use variable names), but this can also fail. Go To Definition in the following example is an example where this doesn't work properly.
my$foo = 1;
subbar {
my$foo = 2;
}
print$foo; # This points to the wrong definition.
I understand that scoping is a difficult topic. With PPI, it would be rather cumbersome - if at all possible - to process Object::Pad code, which right now is a unique selling point of PerlNavigator among the Perl language servers.
The function "Go to Definition" fails to identify the correct definition if a subroutine with the same name is present in another package in the same file, or if the subroutine is a lexical sub.
Here's a demo code:
This code has three subroutines called
show
: "public" subroutines in packages main and Inner, and a lexical subroutine in package Private. When I invoke "Go to Definition" from the places where show is called, it does not select the correct one.It seems that lexical subroutines are not found at all, and the namespace is ignored for public subroutines.
The text was updated successfully, but these errors were encountered: