Open jkeenan opened 4 years ago
You need to compare against the added prefix
use feature 'bitwise';
use warnings 'numeric';
Only the feature bitwise converts the bit_and
into i_bit_and
ops (called nbit_and
in perl5), which will be then we warned against.
bitwise is really enforcing integer context for the 3 logical compare binops. (n is a misnomer)
Just fix your testcase.
Leaving
use p5;
in a program can have a false positive effect on test results. Removing thatuse p5;
way cause errors or warnings, at compile-time or run-time, but at least it lets us know how the program performs under our current implementation of Perl 7 semantics.Case in point. Consider the following program:
Note the absence of either
use strict
oruse warnings
from the program.If I run it as is in Perl 5, I get:
Runs clean. Now suppose I run it with
strict
enabled.Again runs clean. Now suppose I run it with warnings enabled.
Still runs clean.
Now, suppose I run it with the "Perl 7" executable from the
p7
branch, say, at commit 8c5f5218ed6d0fd4eba8e20e2089cb3fcbe35a2c (Jul 19 2020). In this environment, bothstrict
andwarnings
are on by default.Now all unit tests warn -- twice! -- and all unit tests fail.
This is a conundrum. On the one hand, per
perldoc perldiag
:So, none of the arguments to any of the 3 numeric bitwise operators were ever numeric; they were always strings. So when I ran this program in Perl 5 with warnings enabled, I believe I should have gotten warnings -- but I did not.
Under Perl 7 semantics, I am getting "non-numeric" warnings as the documentation would suggest I should. But the ultimate behavior of the program has changed: failures instead of successes.
Now, you may ask, what happens if in your is() testing subroutine, you test for numeric equality rather than string equality. That is, what if you add this:
... and added 3 unit tests to the body of the program:
Now, when I run this under Perl 5, either "raw" or with
-Mstrict
, I get no change in results.However, running it under Perl 5 with warnings enabled, the program emits warnings:
But the additional 3 tests still pass!
Now, under Perl 7:
Warnings in all 6 unit tests -- but when tested with
numeric_is()
the tests pass.What's going on here?
(Real world impact: Once I remove
use p5
fromt/op/bop.t
, all hell breaks loose. Given that the Perl 5 behavior may have been wrong all along, I don't know how to adapt tests to Perl 7.)Thank you very much. Jim Keenan