You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider this program, which will be run from the root directory of a git checkout of the Perl core distribution. The program is adapted from lib/B/Deparse.t.
No change in output. Next, we run it against a Perl 7 executable where we have strict-by-default.
$ ./perl -Ilib ~/tmp/deparse-problem.pl
XXX: /home/jkeenan/gitwork/perl-atoomic-2/perl "-I./lib" "-MO=Deparse" -anl -e 1 2>&1
YYY: Variable "$savebackslash" is not imported at (eval 1) line 25.
Loading compiler backend 'B::Deparse' failed: Global symbol "$savebackslash" requires explicit package name (did you forget to declare "my $savebackslash"?) at (eval 1) line 25.
at -e line 0.
BEGIN failed--compilation aborted.
It fails. Now, as I've been working my way through hundreds of test files in the core distribution, "Variable $___ is not imported" failures can usually be resolved by fully qualifying the variable -- something like $main::savebackslash -- or making the variable a package-scoped global variable -- our $savebackslash.
However, I have had no luck with that approach in this point. That's probably because, in lib/B/Deparse.pm, this variable already is fully qualified.
851 sub compile {
852 my(@args) = @_;
...
862 if ($/ ne "\n" or defined $O::savebackslash) { # deparse -l and -0
863 my $fs = perlstring($/) || 'undef';
864 my $bs = perlstring($O::savebackslash) || 'undef';
865 print qq(BEGIN { \$/ = $fs; \$\\ = $bs; }\n);
866 }
There are many unit tests within lib/B/Deparse.t which fail with this kind of problem. I don't understand B::Deparse well enough to know how to fix them. @atoomic
Thank you very much.
Jim Keenan
The text was updated successfully, but these errors were encountered:
On 8/13/20 11:28 AM, ℕicolas ℝ. wrote:
I think the error comes from O.pm and the patch should be something like
this
diff --git a/ext/B/O.pm b/ext/B/O.pm
index 81c879835b..1388f21822 100644
--- a/ext/B/O.pm
+++ b/ext/B/O.pm
@@ -27,7 +27,8 @@ sub import {
B::save_BEGINs;
}
+ our $savebackslash;
CHECK {
if ($quiet) {
close STDOUT;
open (STDOUT, ">&", $saveout_fh);
note: when running |./perl -Ilib -Mstrict ~/tmp/deparse-problem.pl | you
are not enforcing strict to the perl command you are running later in
the script
The existence of the `O` module completely escaped me. I'll take a look
at that later today.
Thank you very much.
Jim Keenan
Consider this program, which will be run from the root directory of a
git checkout
of the Perl core distribution. The program is adapted fromlib/B/Deparse.t
.We first run it from Perl 5.
We run it again from Perl 5, but this time imposing strictures.
No change in output. Next, we run it against a Perl 7 executable where we have strict-by-default.
It fails. Now, as I've been working my way through hundreds of test files in the core distribution,
"Variable $___ is not imported"
failures can usually be resolved by fully qualifying the variable -- something like$main::savebackslash
-- or making the variable a package-scoped global variable --our $savebackslash
.However, I have had no luck with that approach in this point. That's probably because, in
lib/B/Deparse.pm
, this variable already is fully qualified.There are many unit tests within
lib/B/Deparse.t
which fail with this kind of problem. I don't understand B::Deparse well enough to know how to fix them. @atoomicThank you very much.
Jim Keenan
The text was updated successfully, but these errors were encountered: