This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Warning about experimental bitops
authorFather Chrysostomos <sprout@cpan.org>
Sun, 4 Jan 2015 19:44:03 +0000 (11:44 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 1 Feb 2015 06:03:51 +0000 (22:03 -0800)
op.c
opcode.h
pod/perldiag.pod
regen/opcodes

diff --git a/op.c b/op.c
index b5de89a..db53f97 100644 (file)
--- a/op.c
+++ b/op.c
@@ -9481,6 +9481,13 @@ Perl_ck_bitop(pTHX_ OP *o)
     PERL_ARGS_ASSERT_CK_BITOP;
 
     o->op_private = (U8)(PL_hints & HINT_INTEGER);
+
+    if (o->op_type == OP_NBIT_OR     || o->op_type == OP_SBIT_OR
+     || o->op_type == OP_NBIT_XOR    || o->op_type == OP_SBIT_XOR
+     || o->op_type == OP_NBIT_AND    || o->op_type == OP_SBIT_AND
+     || o->op_type == OP_NCOMPLEMENT || o->op_type == OP_SCOMPLEMENT)
+       Perl_ck_warner_d(aTHX_ packWARN(WARN_EXPERIMENTAL__BITWISE),
+                             "The bitwise feature is experimental");
     if (!(o->op_flags & OPf_STACKED) /* Not an assignment */
            && OP_IS_INFIX_BIT(o->op_type))
     {
index edb2702..cf39a4b 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1492,7 +1492,7 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
        Perl_ck_null,           /* not */
        Perl_ck_bitop,          /* complement */
        Perl_ck_bitop,          /* ncomplement */
-       Perl_ck_null,           /* scomplement */
+       Perl_ck_bitop,          /* scomplement */
        Perl_ck_smartmatch,     /* smartmatch */
        Perl_ck_fun,            /* atan2 */
        Perl_ck_fun,            /* sin */
index e6b0562..877b992 100644 (file)
@@ -5750,6 +5750,18 @@ as a compiler directive.  You may say only one of
 This is to prevent the problem of one module changing the array base out
 from under another module inadvertently.  See L<perlvar/$[> and L<arybase>.
 
+=item The bitwise feature is experimental
+
+(S experimental::bitwise) This warning is emitted if you use bitwise
+operators (C<& | ^ ~ &. |. ^. ~.>) with the "bitwise" feature enabled.
+Simply suppress the warning if you want to use the feature, but know
+that in doing so you are taking the risk of using an experimental
+feature which may change or be removed in a future Perl version:
+
+    no warnings "experimental::bitwise";
+    use feature "bitwise";
+    $x |.= $y;
+
 =item The crypt() function is unimplemented due to excessive paranoia.
 
 (F) Configure couldn't find the crypt() function on your machine,
index cbf38dc..8bbd557 100644 (file)
@@ -177,7 +177,9 @@ i_negate    integer negation (-)    ck_null         ifst1   S
 not            not                     ck_null         ifs1    S
 complement     1's complement (~)      ck_bitop        fsT1    S
 ncomplement    numeric 1's complement (~)      ck_bitop        fsT1    S
-scomplement    string 1's complement (~)       ck_null fsT1    S
+# scomplement uses ck_bitop only for the experimental warning.  Once the
+# warning is gone, this can change to ck_null.
+scomplement    string 1's complement (~)       ck_bitop        fsT1    S
 
 smartmatch     smart match             ck_smartmatch   s2