Perl-LanguageServer icon indicating copy to clipboard operation
Perl-LanguageServer copied to clipboard

Use of uninitialized value in substitution (s///) in _set_breakpont()

Open yzazik opened this issue 4 months ago • 0 comments

Hello, I'm getting this in VSCode, interpreter throws an error here:

sub _set_breakpoint
    {
. . .
    local *dbline = "::_<$filename" if ($filename) ;
    for (my $line = $location; $line <= $location + 10 && $location < @dbline; $line++)
        {
        if ($dbline[$line] != 0)
            {
            $dbline{$line+0} =~ s/^[^\0]*/$condition/; # <-- !!! right here !!!
            return (1, undef, $line, $filename) ;
            }
        }

    return (0, "Line $location for sub $subname is not breakable.") if ($subname) ;
    return (0, "Line $location is not breakable.") ;
    }

In this line $dbline{$line+0} =~ s/^[^\0]*/$condition/; the $dbline initially is being a string scalar, accessing it as $dbline{$line+0} (with curly brackets) would make it a hash with a key equal to $line+0 and value undef, and only then the regex substitution would proceed, so interpreter is correct complaining about uninitialized value. Is this by intent or there is a some sort of bug there or a simple typo? Thank you.

yzazik avatar Sep 18 '25 20:09 yzazik