Skip to content

GoToDefinition fails to find function in path added at runtime? #159

@rymdbar

Description

@rymdbar

To the best of my understanding this is not a duplicate of any other open issue. Please consider these two files:

Greeting.pm

sub say_it {
    print "Hello perl\n";
}

1;

and

hello

#!/usr/bin/env perl

use v5.36;
use warnings;

use lib './';
use Greeting;

sub hello {
    say_it();
}

hello();

If attempting to GoToDefinition on hello(), it does find sub hello. However when doing the same for say_it() my client gives me the message No definitions found, or to express is with was json-rpc:

{
  "method": "textDocument/definition",
  "jsonrpc": "2.0",
  "id": 2,
  "params": {
    "textDocument": {
      "uri": "file:///hello"
    },
    "position": {
      "character": 0,
      "line": 12
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": [
    {
      "uri": "file:///home/cos/hax/hello_polyglot-world/perl/hello",
      "range": {
        "start": {
          "line": 8,
          "character": 0
        },
        "end": {
          "line": 8,
          "character": 500
        }
      }
    }
  ]
}

vs.

{
  "method": "textDocument/definition",
  "jsonrpc": "2.0",
  "id": 3,
  "params": {
    "textDocument": {
      "uri": "file:///hello"
    },
    "position": {
      "character": 4,
      "line": 9
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": []
}

That's a bit unexpected to me, given how the description of PerlNavigator states:

Code Navigation ("Go To Definition") anywhere, including to installed modules and compile-time dependencies

I tried running the -MInquistor mentioned in #69, without really understanding the output. It does contain this row though:

say_it t Greeting.pm main 1

Is this expected behaviour? It seems more trivial than the other reported failures of GoToDefinition, but maybe this is a duplicate after all? or another corner case which is hard to address?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions