lambda variables mysteriously cleared

Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=1922

Reported by Jonas Wallden jonasw@roxen.com

int main()
{
  function my_lambda;

  {
    string foo = "foo", bar = "bar";
    my_lambda = lambda() { werror("foo: %O, bar: %O\n", foo, bar); };
  }

  int really_magic_var;
  my_lambda();

  return 0;
}

The program above generates this output:

foo: 0, bar: "bar"

Commenting out the declaration of really_magic_var suddenly makes the code work again!

Reproducible in both Pike 7.0.307 and Pike 7.2.116.