summaryrefslogtreecommitdiff
path: root/feature.h
diff options
context:
space:
mode:
authorchromatic <chromatic@wgz.org>2022-10-27 11:24:58 +0200
committerYves Orton <demerphq@gmail.com>2022-11-01 09:46:16 +0100
commit1102a6f006f2bb626d2c7f1c5b7d360c28518129 (patch)
treeeb90ea178d14524d853018b788c2c0bc02021d22 /feature.h
parent73d66f354cd4df0324b11e46af48f66bd5c1dd15 (diff)
downloadperl-1102a6f006f2bb626d2c7f1c5b7d360c28518129.tar.gz
Enable `use feature 'module_true'`
Per RFC 18, whenever `use feature 'module_true';` is enabled in a scope, any file required with `require` has an implicit return value of true and will not trigger the "did not return a true value" error condition. This includes logic to use the OPf_SPECIAL flag for OP_RETURN listops to indicate that the module_true feature is in effect when it executes. This flag plays no role unless the OP_RETURN tail calls the pp_leaveeval logic, so it doesn't affect normal sub returns.
Diffstat (limited to 'feature.h')
-rw-r--r--feature.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/feature.h b/feature.h
index 08061e12c8..900a1b990e 100644
--- a/feature.h
+++ b/feature.h
@@ -22,16 +22,17 @@
#define FEATURE_FC_BIT 0x0080
#define FEATURE_INDIRECT_BIT 0x0100
#define FEATURE_ISA_BIT 0x0200
-#define FEATURE_MULTIDIMENSIONAL_BIT 0x0400
-#define FEATURE_POSTDEREF_QQ_BIT 0x0800
-#define FEATURE_REFALIASING_BIT 0x1000
-#define FEATURE_SAY_BIT 0x2000
-#define FEATURE_SIGNATURES_BIT 0x4000
-#define FEATURE_STATE_BIT 0x8000
-#define FEATURE_SWITCH_BIT 0x10000
-#define FEATURE_TRY_BIT 0x20000
-#define FEATURE_UNIEVAL_BIT 0x40000
-#define FEATURE_UNICODE_BIT 0x80000
+#define FEATURE_MODULE_TRUE_BIT 0x0400
+#define FEATURE_MULTIDIMENSIONAL_BIT 0x0800
+#define FEATURE_POSTDEREF_QQ_BIT 0x1000
+#define FEATURE_REFALIASING_BIT 0x2000
+#define FEATURE_SAY_BIT 0x4000
+#define FEATURE_SIGNATURES_BIT 0x8000
+#define FEATURE_STATE_BIT 0x10000
+#define FEATURE_SWITCH_BIT 0x20000
+#define FEATURE_TRY_BIT 0x40000
+#define FEATURE_UNIEVAL_BIT 0x80000
+#define FEATURE_UNICODE_BIT 0x100000
#define FEATURE_BUNDLE_DEFAULT 0
#define FEATURE_BUNDLE_510 1
@@ -151,6 +152,13 @@
FEATURE_IS_ENABLED_MASK(FEATURE___SUB___BIT)) \
)
+#define FEATURE_MODULE_TRUE_IS_ENABLED \
+ ( \
+ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_537 \
+ || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
+ FEATURE_IS_ENABLED_MASK(FEATURE_MODULE_TRUE_BIT)) \
+ )
+
#define FEATURE_REFALIASING_IS_ENABLED \
( \
CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
@@ -333,7 +341,12 @@ S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen,
return;
case 'm':
- if (keylen == sizeof("feature_more_delims")-1
+ if (keylen == sizeof("feature_module_true")-1
+ && memcmp(subf+1, "odule_true", keylen - sizeof("feature_")) == 0) {
+ mask = FEATURE_MODULE_TRUE_BIT;
+ break;
+ }
+ else if (keylen == sizeof("feature_more_delims")-1
&& memcmp(subf+1, "ore_delims", keylen - sizeof("feature_")) == 0) {
mask = FEATURE_MORE_DELIMS_BIT;
break;