Branch: refs/heads/davem/eval_compiled
  Home:   https://github.com/Perl/perl5
  Commit: d06d7106c2a33ff04a79463396bd9139f41380e3
      
https://github.com/Perl/perl5/commit/d06d7106c2a33ff04a79463396bd9139f41380e3
  Author: David Mitchell <da...@iabyn.com>
  Date:   2024-06-17 (Mon, 17 Jun 2024)

  Changed paths:
    M cv.h
    M dump.c
    M op.c
    M pad.c
    M t/op/eval.t

  Log Message:
  -----------
  add CvEVAL_COMPILED() flag and fix closure bug.

EVAL CVs are treated a bit weirdly: their CvROOT() and CvSTART() fields
don't get populated; instead the current values are stored in the
PL_eval_root and PL_eval_start variables while they are being executed.

This caused a bug in closures and nested evals when an inner eval was
repeated twice. The first inner eval accessed an outer lexical, which
caused a fake cache entry to be added to the outer eval's pad. The
second inner eval finds this cached entry, but incorrectly concludes
that the outer eval is in fact an anon sub prototype and issues a
'variable is not available' warning. This is due to this simplistic
definition in pad.c:

    #define CvCOMPILED(cv) CvROOT(cv)

This commit adds a new flag, CvEVAL_COMPILED(), to indicate a
fully-compiled EVAL CV. This allows us to work around the limitation.

In an ideal world this would have been fixed instead by making EVAL CVs
first-class citizens with CvROOT() etc, but plenty of stuff seems to
assume otherwise. So I took the path of least resistance.

See https://www.perlmonks.org/?node_id=11158351



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to