richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 51 forks source link

Debug Console doesn't see loaded Modules #104

Closed dseynhae closed 3 years ago

dseynhae commented 3 years ago

I expect the Debug Console to have access to all modules that are loaded by the program. Consider:

test.pl

package main 1.0;
use 5.030;
use strict;
use warnings;
use Carp;
use English '-no_match_vars';

say 'world' or carp "Problem saying things [$OS_ERROR]\n";

1;

When I start a Debug Session, the feature bundle 5.030 is already loaded. Yet when I tray to say something in the Debug Console, the command is not recognized. If I load the feature bundle on the same line as the say command, then it is working. But I shouldn't have to do that:

image

richterger commented 3 years ago

From the perl documentation "use VERSION also lexically enables all features available in the requested version". While the Debug Console run the code in the same package as your current program, so symbols imported by use will work, the lexical scope is different, beause it is not supported by the Perl interpreter to run in the same lexcial scope. The debugger only emulates for access of variable the lexical scope. Because of this reason this can't be fixed. The problem only applies to lexcial scoped use statements.