summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-03-18 14:37:01 +1100
committerYves Orton <demerphq@gmail.com>2022-10-26 11:11:08 +0200
commita73e2f42e4d90aabd3c1f9b45b5b18fab652e36e (patch)
treea49777fb3f48fdde784a7b68b567053ed91c2379
parentee05e6d8953bcb0842d59e3379842b4df6929b1a (diff)
downloadperl-a73e2f42e4d90aabd3c1f9b45b5b18fab652e36e.tar.gz
op.c - copy cop_features to the COP inserted into the OP tree
All current features are compile-time, so this hasn't been an issue, but my current implementation of the autovivification issue checks features at runtime, which failed to work correctly if non-bundle features were set. This commit fixes things so that run-time default-on features also work properly, by setting each COP's cop_features to the value of the bits set at the COP's compile time - ie the same approach as cop_hints.
-rw-r--r--cop.h2
-rw-r--r--op.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/cop.h b/cop.h
index ab6f507b20..f53f6aa7cb 100644
--- a/cop.h
+++ b/cop.h
@@ -558,6 +558,8 @@ string C<p>, creating the package if necessary.
#define CopHINTHASH_get(c) ((COPHH*)((c)->cop_hints_hash))
#define CopHINTHASH_set(c,h) ((c)->cop_hints_hash = (h))
+#define CopFEATURES_setfrom(dst, src) ((dst)->cop_features = (src)->cop_features)
+
/*
=for apidoc Am|SV *|cop_hints_fetch_pv |const COP *cop|const char *key |U32 hash|U32 flags
=for apidoc_item|SV *|cop_hints_fetch_pvn|const COP *cop|const char *key|STRLEN keylen|U32 hash|U32 flags
diff --git a/op.c b/op.c
index f67d38cf68..481158db3f 100644
--- a/op.c
+++ b/op.c
@@ -8225,6 +8225,7 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
cop->cop_seq = seq;
cop->cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings);
CopHINTHASH_set(cop, cophh_copy(CopHINTHASH_get(PL_curcop)));
+ CopFEATURES_setfrom(cop, PL_curcop);
if (label) {
Perl_cop_store_label(aTHX_ cop, label, strlen(label), utf8);