richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 51 forks source link

Problem debugging loop with each statement #107

Closed dseynhae closed 2 years ago

dseynhae commented 3 years ago

Minimal reproducable test case

package main 1.0;

my $options = {
  new           => 'zero',
  compiler_args => [ 'one', 'two' ],
  name          => 'three',
};

my %options = %{$options};
while ( my ( $key, $value ) = each %options ) {
  print "<$key>=><$value>\n";
}

1;

Expected behavior

When running the debugger without stepping through the code, we get the expected result:

<new>=><zero>
<compiler_args>=><ARRAY(0x7ffff31f6c40)>
<name>=><three>

Problem/Bug

When stepping through the code, the %options hash gets reset, and we keep getting the very first each iteration:

image

dseynhae commented 3 years ago

I just noticed that if you step (click) fast enough, the each doesn't reset, and we're getting the correct result. But you don't have time at all to inspect the results between each click.

mpetronic commented 2 years ago

I just started using this plugin in vscode. It is generally very good and thank you for contributing it. I am seeing this same issue in "each" loops.

richterger commented 2 years ago

It's fixed and will be in the next release

mpetronic commented 2 years ago

Thank you. Look forward to stepping through loops more predictably now. :)