New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error for "do undef" references "require" instead #14916
Comments
From @rjbsCreated by @rjbsperl -e 'do undef' Since 5.22.0, this reports "Missing or undefined argument to require", "do undef" and "do()" should say "...to do", not "...to require" (It's too bad we don't traditionally quote the builtins in these messages, as Perl Info
|
From @jkeenanOn Thu Sep 17 06:37:08 2015, rjbs wrote:
These warnings are defined in PP(pp_require) in pp_ctl.c. There are several other points where it is indicated that the dofile opcode is implemented via pp_require. So, at a high level, we would probably need a PP(pp_do) in pp_ctl.c. But pp_require is several hundreds line of code long; I'm guessing we wouldn't need all of it for a pp_do.
-- |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Sun Sep 20 15:57:21 2015, jkeenan wrote:
You don't need to duplicate pp_require, we have a macro to find the description of an op. See the attached. Tony |
From @tonycoz0001-perl-126084-report-the-correct-op-in-pp_require.patchFrom 0cf23372b33f16f0d3977c88c901b7f04b3cb21d Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 21 Sep 2015 09:43:14 +1000
Subject: [perl #126084] report the correct op in pp_require
pp_require implements both require and do "file", but always reported
the error as being for require.
---
pod/perldiag.pod | 12 ++++++++----
pp_ctl.c | 8 ++++----
t/lib/croak/pp_ctl | 20 ++++++++++++++++++++
t/lib/warnings/pp_ctl | 13 +++++++++++++
4 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 6af1245..eeb658a 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -3397,11 +3397,15 @@ can vary from one line to the next.
(S syntax) This is an educated guess made in conjunction with the message
"%s found where operator expected". Often the missing operator is a comma.
-=item Missing or undefined argument to require
+=item Missing or undefined argument to %s
-(F) You tried to call require with no argument or with an undefined
-value as an argument. Require expects either a package name or a
-file-specification as an argument. See L<perlfunc/require>.
+(F) You tried to call require or do with no argument or with an undefined
+value as an argument.
+
+Require expects either a package name or a file-specification as an
+argument. See L<perlfunc/require>.
+
+Do expected a file-specification as an argument. See L<perlfunc/do>.
=item Missing right brace on \%c{} in regex; marked by S<<-- HERE> in m/%s/
diff --git a/pp_ctl.c b/pp_ctl.c
index 852ec36..8e05d53 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3686,12 +3686,12 @@ PP(pp_require)
RETPUSHYES;
}
if (!SvOK(sv))
- DIE(aTHX_ "Missing or undefined argument to require");
+ DIE(aTHX_ "Missing or undefined argument to %s", OP_DESC(PL_op));
name = SvPV_nomg_const(sv, len);
if (!(name && len > 0 && *name))
- DIE(aTHX_ "Missing or undefined argument to require");
+ DIE(aTHX_ "Missing or undefined argument to %s", OP_DESC(PL_op));
- if (!IS_SAFE_PATHNAME(name, len, "require")) {
+ if (!IS_SAFE_PATHNAME(name, len, OP_DESC(PL_op))) {
DIE(aTHX_ "Can't locate %s: %s",
pv_escape(newSVpvs_flags("",SVs_TEMP),SvPVX(sv),SvCUR(sv),
SvCUR(sv)*2,NULL, SvUTF8(sv)?PERL_PV_ESCAPE_UNI:0),
@@ -3899,7 +3899,7 @@ PP(pp_require)
dirlen = 0;
}
- if (!IS_SAFE_SYSCALL(dir, dirlen, "@INC entry", "require"))
+ if (!IS_SAFE_SYSCALL(dir, dirlen, "@INC entry", OP_DESC(PL_op)))
continue;
#ifdef VMS
if ((unixdir =
diff --git a/t/lib/croak/pp_ctl b/t/lib/croak/pp_ctl
index ee1edba..0ce9166 100644
--- a/t/lib/croak/pp_ctl
+++ b/t/lib/croak/pp_ctl
@@ -16,3 +16,23 @@ use 5.01;
default{}
EXPECT
Can't "default" outside a topicalizer at - line 2.
+########
+# NAME error on require undef
+require undef
+EXPECT
+Missing or undefined argument to require at - line 1.
+########
+# NAME error on require ""
+require ""
+EXPECT
+Missing or undefined argument to require at - line 1.
+########
+# NAME error on do undef
+do undef
+EXPECT
+Missing or undefined argument to do "file" at - line 1.
+########
+# NAME error on do ""
+do ""
+EXPECT
+Missing or undefined argument to do "file" at - line 1.
diff --git a/t/lib/warnings/pp_ctl b/t/lib/warnings/pp_ctl
index 9b3f298..2959fef 100644
--- a/t/lib/warnings/pp_ctl
+++ b/t/lib/warnings/pp_ctl
@@ -251,3 +251,16 @@ EXPECT
use warnings;
eval 'use 5.006; use 5.10.0';
EXPECT
+########
+# NAME \0 in require/do arguments and @INC
+use warnings;
+eval 'require "a\0b";';
+eval 'do "a\0b"';
+push @INC, "a\0b";
+eval 'require "some-unknown-filename"';
+eval 'do "some-unknown-filename"';
+EXPECT
+Invalid \0 character in pathname for require: a\0b at (eval 1) line 1.
+Invalid \0 character in pathname for do "file": a\0b at (eval 2) line 1.
+Invalid \0 character in @INC entry for require: a\0b at (eval 3) line 1.
+Invalid \0 character in @INC entry for do "file": a\0b at (eval 4) line 1.
--
2.1.4
|
From @rjbs* Tony Cook via RT <perlbug-followup@perl.org> [2015-09-20T19:44:59]
Thanks!
^--- Verb tense disagreement -- |
From @tonycozOn Sun Sep 20 16:50:17 2015, perl.p5p@rjbs.manxome.org wrote:
Oops, updated patch. Tony |
From @tonycoz0001-perl-126084-report-the-correct-op-in-pp_require.patchFrom e6c2a82191fb03d6a76ba7e238cdccae1c859af2 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 21 Sep 2015 10:11:39 +1000
Subject: [perl #126084] report the correct op in pp_require
pp_require implements both require and do "file", but always reported
the error as being for require.
---
pod/perldiag.pod | 12 ++++++++----
pp_ctl.c | 8 ++++----
t/lib/croak/pp_ctl | 20 ++++++++++++++++++++
t/lib/warnings/pp_ctl | 13 +++++++++++++
4 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 6af1245..2e41502 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -3397,11 +3397,15 @@ can vary from one line to the next.
(S syntax) This is an educated guess made in conjunction with the message
"%s found where operator expected". Often the missing operator is a comma.
-=item Missing or undefined argument to require
+=item Missing or undefined argument to %s
-(F) You tried to call require with no argument or with an undefined
-value as an argument. Require expects either a package name or a
-file-specification as an argument. See L<perlfunc/require>.
+(F) You tried to call require or do with no argument or with an undefined
+value as an argument.
+
+Require expects either a package name or a file-specification as an
+argument. See L<perlfunc/require>.
+
+Do expects a file-specification as an argument. See L<perlfunc/do>.
=item Missing right brace on \%c{} in regex; marked by S<<-- HERE> in m/%s/
diff --git a/pp_ctl.c b/pp_ctl.c
index 852ec36..8e05d53 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3686,12 +3686,12 @@ PP(pp_require)
RETPUSHYES;
}
if (!SvOK(sv))
- DIE(aTHX_ "Missing or undefined argument to require");
+ DIE(aTHX_ "Missing or undefined argument to %s", OP_DESC(PL_op));
name = SvPV_nomg_const(sv, len);
if (!(name && len > 0 && *name))
- DIE(aTHX_ "Missing or undefined argument to require");
+ DIE(aTHX_ "Missing or undefined argument to %s", OP_DESC(PL_op));
- if (!IS_SAFE_PATHNAME(name, len, "require")) {
+ if (!IS_SAFE_PATHNAME(name, len, OP_DESC(PL_op))) {
DIE(aTHX_ "Can't locate %s: %s",
pv_escape(newSVpvs_flags("",SVs_TEMP),SvPVX(sv),SvCUR(sv),
SvCUR(sv)*2,NULL, SvUTF8(sv)?PERL_PV_ESCAPE_UNI:0),
@@ -3899,7 +3899,7 @@ PP(pp_require)
dirlen = 0;
}
- if (!IS_SAFE_SYSCALL(dir, dirlen, "@INC entry", "require"))
+ if (!IS_SAFE_SYSCALL(dir, dirlen, "@INC entry", OP_DESC(PL_op)))
continue;
#ifdef VMS
if ((unixdir =
diff --git a/t/lib/croak/pp_ctl b/t/lib/croak/pp_ctl
index ee1edba..0ce9166 100644
--- a/t/lib/croak/pp_ctl
+++ b/t/lib/croak/pp_ctl
@@ -16,3 +16,23 @@ use 5.01;
default{}
EXPECT
Can't "default" outside a topicalizer at - line 2.
+########
+# NAME error on require undef
+require undef
+EXPECT
+Missing or undefined argument to require at - line 1.
+########
+# NAME error on require ""
+require ""
+EXPECT
+Missing or undefined argument to require at - line 1.
+########
+# NAME error on do undef
+do undef
+EXPECT
+Missing or undefined argument to do "file" at - line 1.
+########
+# NAME error on do ""
+do ""
+EXPECT
+Missing or undefined argument to do "file" at - line 1.
diff --git a/t/lib/warnings/pp_ctl b/t/lib/warnings/pp_ctl
index 9b3f298..2959fef 100644
--- a/t/lib/warnings/pp_ctl
+++ b/t/lib/warnings/pp_ctl
@@ -251,3 +251,16 @@ EXPECT
use warnings;
eval 'use 5.006; use 5.10.0';
EXPECT
+########
+# NAME \0 in require/do arguments and @INC
+use warnings;
+eval 'require "a\0b";';
+eval 'do "a\0b"';
+push @INC, "a\0b";
+eval 'require "some-unknown-filename"';
+eval 'do "some-unknown-filename"';
+EXPECT
+Invalid \0 character in pathname for require: a\0b at (eval 1) line 1.
+Invalid \0 character in pathname for do "file": a\0b at (eval 2) line 1.
+Invalid \0 character in @INC entry for require: a\0b at (eval 3) line 1.
+Invalid \0 character in @INC entry for do "file": a\0b at (eval 4) line 1.
--
2.1.4
|
From @jkeenanOn Sun Sep 20 17:13:19 2015, tonyc wrote:
+1. Smoking in branch smoke-me/jkeenan/126084-dofile. -- |
From @jkeenanOn Mon Sep 21 18:28:35 2015, jkeenan wrote:
Tony: Smoke reports (mostly from your own smokers) can be found here: http://perl.develop-help.com/?b=smoke-me%2Fjkeenan%2F126084-dofile My sense is that there are no new test failures as a result of your patch -- just the usual suspects. Shall we proceed to apply? Thank you very much. -- |
From @jkeenanOn Tue, 29 Sep 2015 22:09:03 GMT, jkeenan wrote:
Though this branch got smoked, it was never applied to blead and the ticket remains unresolved. TonyC, can you take a look? Thank you very much. -- |
From @tonycozOn Thu, 20 Sep 2018 16:30:16 -0700, jkeenan wrote:
This was fixed by 33fe195. Since it was previously fixed I'm resolving it instead of marking it pending release. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#126084 (status was 'resolved')
Searchable as RT126084$
The text was updated successfully, but these errors were encountered: