-
Notifications
You must be signed in to change notification settings - Fork 560
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
BEGIN {require 5.011} imports features #9863
Comments
From @nwc10Created by @nwc10It is documented that C<use 5.011;> (etc) implicitly use feature. Hence $ ./perl -Ilib -e 'say "Hi"' However, it is not documented that C<require 5.011> does this. Hence this $ ./perl -Ilib -e 'BEGIN {require 5.011}; say "Hi"' That should fail with the "String found" error. (Zefram spotted this) Nicholas Clark Perl Info
|
From Robin.Barker@npl.co.uk
I have fixed this by introducing a separate opcode for use, OP_USE, There are lots of collateral changes and this may not be the right In particular, Safe.pm will not work as before wrt to require/use Robin |
From Robin.Barker@npl.co.uk0002-add-OP_USE-to-distinguish-use-from-BEGIN-require.patchFrom 30ed5a30ebf7db6ac54a838b2d7fa8edd164c842 Mon Sep 17 00:00:00 2001
From: Robin Barker <Robin.Barker@npl.co.uk>
Date: Fri, 11 Sep 2009 15:46:41 +0100
Subject: [PATCH 2/2] add OP_USE to distinguish use from BEGIN{require}
---
embed.h | 2 ++
ext/B-Deparse/Deparse.pm | 2 +-
ext/B/t/optree_specials.t | 36 ++++++++++++++++++------------------
ext/Opcode/Opcode.pm | 2 +-
ext/Safe/t/safeload.t | 2 +-
ext/Safe/t/safeuniversal.t | 2 +-
ext/Storable/t/code.t | 2 +-
op.c | 4 +++-
opcode.h | 5 +++++
opcode.pl | 6 +++++-
opnames.h | 3 ++-
pp.sym | 1 +
pp_ctl.c | 29 +++++++++++++++++------------
pp_proto.h | 1 +
t/lib/feature/implicit | 14 ++++++++++++++
15 files changed, 73 insertions(+), 38 deletions(-)
diff --git a/embed.h b/embed.h
index 817c291..e56355b 100644
--- a/embed.h
+++ b/embed.h
@@ -2374,6 +2374,7 @@
#define pp_unshift Perl_pp_unshift
#define pp_unstack Perl_pp_unstack
#define pp_untie Perl_pp_untie
+#define pp_use Perl_pp_use
#define pp_utime Perl_pp_utime
#define pp_values Perl_pp_values
#define pp_vec Perl_pp_vec
@@ -4741,6 +4742,7 @@
#define pp_unshift() Perl_pp_unshift(aTHX)
#define pp_unstack() Perl_pp_unstack(aTHX)
#define pp_untie() Perl_pp_untie(aTHX)
+#define pp_use() Perl_pp_use(aTHX)
#define pp_utime() Perl_pp_utime(aTHX)
#define pp_values() Perl_pp_values(aTHX)
#define pp_vec() Perl_pp_vec(aTHX)
diff --git a/ext/B-Deparse/Deparse.pm b/ext/B-Deparse/Deparse.pm
index df7ed31..6c5adbf 100644
--- a/ext/B-Deparse/Deparse.pm
+++ b/ext/B-Deparse/Deparse.pm
@@ -372,7 +372,7 @@ sub begin_is_use {
return if $lineseq->name ne "lineseq";
my $req_op = $lineseq->first->sibling;
- return if $req_op->name ne "require";
+ return if $req_op->name ne "use";
my $module;
if ($req_op->first->private & OPpCONST_BARE) {
diff --git a/ext/B/t/optree_specials.t b/ext/B/t/optree_specials.t
index 1f81323..e38a2fd 100644
--- a/ext/B/t/optree_specials.t
+++ b/ext/B/t/optree_specials.t
@@ -51,7 +51,7 @@ checkOptree ( name => 'BEGIN',
# b <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->b
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$ ->2
-# 3 <1> require sK/1 ->4
+# 3 <1> use sK/1 ->4
# 2 <$> const[PV "strict.pm"] s/BARE ->3
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$ ->5
# - <@> lineseq K ->-
@@ -65,7 +65,7 @@ checkOptree ( name => 'BEGIN',
# m <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq K ->m
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$ ->d
-# e <1> require sK/1 ->f
+# e <1> use sK/1 ->f
# d <$> const[PV "strict.pm"] s/BARE ->e
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$ ->g
# - <@> lineseq K ->-
@@ -79,7 +79,7 @@ checkOptree ( name => 'BEGIN',
# x <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->x
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$ ->o
-# p <1> require sK/1 ->q
+# p <1> use sK/1 ->q
# o <$> const[PV "warnings.pm"] s/BARE ->p
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$ ->r
# - <@> lineseq K ->-
@@ -101,7 +101,7 @@ EOT_EOT
# b <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->b
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$ ->2
-# 3 <1> require sK/1 ->4
+# 3 <1> use sK/1 ->4
# 2 <$> const(PV "strict.pm") s/BARE ->3
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$ ->5
# - <@> lineseq K ->-
@@ -115,7 +115,7 @@ EOT_EOT
# m <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq K ->m
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$ ->d
-# e <1> require sK/1 ->f
+# e <1> use sK/1 ->f
# d <$> const(PV "strict.pm") s/BARE ->e
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$ ->g
# - <@> lineseq K ->-
@@ -129,7 +129,7 @@ EOT_EOT
# x <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->x
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$ ->o
-# p <1> require sK/1 ->q
+# p <1> use sK/1 ->q
# o <$> const(PV "warnings.pm") s/BARE ->p
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$ ->r
# - <@> lineseq K ->-
@@ -251,7 +251,7 @@ checkOptree ( name => 'all of BEGIN END INIT CHECK UNITCHECK -exec',
# BEGIN 1:
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 2 <$> const[PV "strict.pm"] s/BARE
-# 3 <1> require sK/1
+# 3 <1> use sK/1
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 5 <;> nextstate(B::Concise -275 Concise.pm:356) :*,&,{,$
# 6 <0> pushmark s
@@ -263,7 +263,7 @@ checkOptree ( name => 'all of BEGIN END INIT CHECK UNITCHECK -exec',
# BEGIN 2:
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# d <$> const[PV "strict.pm"] s/BARE
-# e <1> require sK/1
+# e <1> use sK/1
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# g <;> nextstate(B::Concise -265 Concise.pm:367) :*,&,$
# h <0> pushmark s
@@ -275,7 +275,7 @@ checkOptree ( name => 'all of BEGIN END INIT CHECK UNITCHECK -exec',
# BEGIN 3:
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# o <$> const[PV "warnings.pm"] s/BARE
-# p <1> require sK/1
+# p <1> use sK/1
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# r <;> nextstate(B::Concise -254 Concise.pm:386) :*,&,{,$
# s <0> pushmark s
@@ -313,7 +313,7 @@ EOT_EOT
# BEGIN 1:
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 2 <$> const(PV "strict.pm") s/BARE
-# 3 <1> require sK/1
+# 3 <1> use sK/1
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 5 <;> nextstate(B::Concise -275 Concise.pm:356) :*,&,{,$
# 6 <0> pushmark s
@@ -325,7 +325,7 @@ EOT_EOT
# BEGIN 2:
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# d <$> const(PV "strict.pm") s/BARE
-# e <1> require sK/1
+# e <1> use sK/1
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# g <;> nextstate(B::Concise -265 Concise.pm:367) :*,&,$
# h <0> pushmark s
@@ -337,7 +337,7 @@ EOT_EOT
# BEGIN 3:
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# o <$> const(PV "warnings.pm") s/BARE
-# p <1> require sK/1
+# p <1> use sK/1
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# r <;> nextstate(B::Concise -254 Concise.pm:386) :*,&,{,$
# s <0> pushmark s
@@ -386,7 +386,7 @@ checkOptree ( name => 'regression test for patch 25352',
# BEGIN 1:
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 2 <$> const[PV "strict.pm"] s/BARE
-# 3 <1> require sK/1
+# 3 <1> use sK/1
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 5 <;> nextstate(B::Concise -275 Concise.pm:356) :*,&,{,$
# 6 <0> pushmark s
@@ -398,7 +398,7 @@ checkOptree ( name => 'regression test for patch 25352',
# BEGIN 2:
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# d <$> const[PV "strict.pm"] s/BARE
-# e <1> require sK/1
+# e <1> use sK/1
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# g <;> nextstate(B::Concise -265 Concise.pm:367) :*,&,$
# h <0> pushmark s
@@ -410,7 +410,7 @@ checkOptree ( name => 'regression test for patch 25352',
# BEGIN 3:
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# o <$> const[PV "warnings.pm"] s/BARE
-# p <1> require sK/1
+# p <1> use sK/1
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# r <;> nextstate(B::Concise -254 Concise.pm:386) :*,&,{,$
# s <0> pushmark s
@@ -423,7 +423,7 @@ EOT_EOT
# BEGIN 1:
# 1 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 2 <$> const(PV "strict.pm") s/BARE
-# 3 <1> require sK/1
+# 3 <1> use sK/1
# 4 <;> nextstate(B::Concise -275 Concise.pm:356) v:*,&,{,$
# 5 <;> nextstate(B::Concise -275 Concise.pm:356) :*,&,{,$
# 6 <0> pushmark s
@@ -435,7 +435,7 @@ EOT_EOT
# BEGIN 2:
# c <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# d <$> const(PV "strict.pm") s/BARE
-# e <1> require sK/1
+# e <1> use sK/1
# f <;> nextstate(B::Concise -265 Concise.pm:367) v:*,&,$
# g <;> nextstate(B::Concise -265 Concise.pm:367) :*,&,$
# h <0> pushmark s
@@ -447,7 +447,7 @@ EOT_EOT
# BEGIN 3:
# n <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# o <$> const(PV "warnings.pm") s/BARE
-# p <1> require sK/1
+# p <1> use sK/1
# q <;> nextstate(B::Concise -254 Concise.pm:386) v:*,&,{,$
# r <;> nextstate(B::Concise -254 Concise.pm:386) :*,&,{,$
# s <0> pushmark s
diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm
index d778294..e9ca4bb 100644
--- a/ext/Opcode/Opcode.pm
+++ b/ext/Opcode/Opcode.pm
@@ -541,7 +541,7 @@ SystemV Interprocess Communications:
This tag holds opcodes related to loading modules and getting information
about calling environment and args.
- require dofile
+ require dofile use
caller
=item :still_to_be_decided
diff --git a/ext/Safe/t/safeload.t b/ext/Safe/t/safeload.t
index 2d2c3cc..a3f2f04 100644
--- a/ext/Safe/t/safeload.t
+++ b/ext/Safe/t/safeload.t
@@ -21,6 +21,6 @@ use Safe;
plan(tests => 1);
my $c = new Safe;
-$c->permit(qw(require caller entereval unpack));
+$c->permit(qw(:load entereval unpack));
my $r = $c->reval(q{ use version; 1 });
ok( defined $r, "Can load version.pm in a Safe compartment" ) or diag $@;
diff --git a/ext/Safe/t/safeuniversal.t b/ext/Safe/t/safeuniversal.t
index 95867c5..30b987a 100644
--- a/ext/Safe/t/safeuniversal.t
+++ b/ext/Safe/t/safeuniversal.t
@@ -16,7 +16,7 @@ use Safe;
plan(tests => 6);
my $c = new Safe;
-$c->permit(qw(require caller));
+$c->permit(qw(:load));
my $no_warn_redef = ($] != 5.008009)
? q(no warnings 'redefine';)
diff --git a/ext/Storable/t/code.t b/ext/Storable/t/code.t
index dd2a96e..336e316 100644
--- a/ext/Storable/t/code.t
+++ b/ext/Storable/t/code.t
@@ -237,7 +237,7 @@ ok(prototype($thawed->[4]), prototype($obj[0]->[4]));
{
my $safe = new Safe;
# because of opcodes used in "use strict":
- $safe->permit(qw(:default require caller));
+ $safe->permit(qw(:default :load));
local $Storable::Eval = sub { $safe->reval(shift) };
$freezed = freeze $obj[0]->[1];
diff --git a/op.c b/op.c
index c6f38fa..255af94 100644
--- a/op.c
+++ b/op.c
@@ -1186,6 +1186,7 @@ Perl_scalarvoid(pTHX_ OP *o)
scalarkids(o);
break;
case OP_REQUIRE:
+ case OP_USE:
/* all requires must return a boolean value */
o->op_flags &= ~OPf_WANT;
/* FALL THROUGH */
@@ -1284,6 +1285,7 @@ Perl_list(pTHX_ OP *o)
PL_curcop = &PL_compiling;
break;
case OP_REQUIRE:
+ case OP_USE:
/* all requires must return a boolean value */
o->op_flags &= ~OPf_WANT;
return scalar(o);
@@ -3914,7 +3916,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
NULL,
append_elem(OP_LINESEQ,
append_elem(OP_LINESEQ,
- newSTATEOP(0, NULL, newUNOP(OP_REQUIRE, 0, idop)),
+ newSTATEOP(0, NULL, newUNOP(OP_USE, 0, idop)),
newSTATEOP(0, NULL, veop)),
newSTATEOP(0, NULL, imop) ));
diff --git a/opcode.h b/opcode.h
index aa57e21..9b2279f 100644
--- a/opcode.h
+++ b/opcode.h
@@ -398,6 +398,7 @@ EXTCONST char* const PL_op_name[] = {
"lock",
"once",
"custom",
+ "use",
};
#endif
@@ -770,6 +771,7 @@ EXTCONST char* const PL_op_desc[] = {
"lock",
"once",
"unknown custom operator",
+ "use",
};
#endif
@@ -1156,6 +1158,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
MEMBER_TO_FPTR(Perl_pp_lock),
MEMBER_TO_FPTR(Perl_pp_once),
MEMBER_TO_FPTR(Perl_unimplemented_op), /* Perl_pp_custom */
+ MEMBER_TO_FPTR(Perl_pp_require), /* Perl_pp_use */
}
#endif
#ifdef PERL_PPADDR_INITED
@@ -1539,6 +1542,7 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
MEMBER_TO_FPTR(Perl_ck_rfun), /* lock */
MEMBER_TO_FPTR(Perl_ck_null), /* once */
MEMBER_TO_FPTR(Perl_ck_null), /* custom */
+ MEMBER_TO_FPTR(Perl_ck_require), /* use */
}
#endif
#ifdef PERL_CHECK_INITED
@@ -1916,6 +1920,7 @@ EXTCONST U32 PL_opargs[] = {
0x0000f604, /* lock */
0x00000600, /* once */
0x00000000, /* custom */
+ 0x000136c0, /* use */
};
#endif
diff --git a/opcode.pl b/opcode.pl
index 2cc242f..3ab91e1 100755
--- a/opcode.pl
+++ b/opcode.pl
@@ -65,7 +65,7 @@ my @raw_alias = (
Perl_pp_null => [qw(scalar regcmaybe lineseq scope)],
Perl_pp_goto => ['dump'],
- Perl_pp_require => ['dofile'],
+ Perl_pp_require => ['dofile', 'use'],
Perl_pp_untie => ['dbmclose'],
Perl_pp_sysread => [qw(read recv)],
Perl_pp_sysseek => ['seek'],
@@ -1116,3 +1116,7 @@ lock lock ck_rfun s% R
once once ck_null |
custom unknown custom operator ck_null 0
+
+# To distinguish 'use' from 'BEGIN{require}'
+
+use use ck_require du% S?
diff --git a/opnames.h b/opnames.h
index 3914ea8..802b55b 100644
--- a/opnames.h
+++ b/opnames.h
@@ -380,10 +380,11 @@ typedef enum opcode {
OP_LOCK = 362,
OP_ONCE = 363,
OP_CUSTOM = 364,
+ OP_USE = 365,
OP_max
} opcode;
-#define MAXO 365
+#define MAXO 366
#define OP_phoney_INPUT_ONLY -1
#define OP_phoney_OUTPUT_ONLY -2
diff --git a/pp.sym b/pp.sym
index 9a2a6b2..ba427cf 100644
--- a/pp.sym
+++ b/pp.sym
@@ -408,5 +408,6 @@ Perl_pp_getlogin
Perl_pp_syscall
Perl_pp_lock
Perl_pp_once
+Perl_pp_use
# ex: set ro:
diff --git a/pp_ctl.c b/pp_ctl.c
index e69bf0c..80ea2f6 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1600,7 +1600,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
* minimal fix --GSAR */
PL_curcop = cx->blk_oldcop;
- if (optype == OP_REQUIRE) {
+ if (optype == OP_REQUIRE || optype == OP_USE) {
const char* const msg = SvPVx_nolen_const(ERRSV);
SV * const nsv = cx->blk_eval.old_namesv;
(void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
@@ -2112,7 +2112,7 @@ PP(pp_return)
if (CxTRYBLOCK(cx))
break;
lex_end();
- if (optype == OP_REQUIRE &&
+ if ((optype == OP_REQUIRE || optype == OP_USE) &&
(MARK == SP || (gimme == G_SCALAR && !SvTRUE(*SP))) )
{
/* Unassume the success we assumed earlier. */
@@ -2980,7 +2980,8 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
dVAR; dSP;
OP * const saveop = PL_op;
- PL_in_eval = ((saveop && saveop->op_type == OP_REQUIRE)
+ PL_in_eval = ((saveop && (saveop->op_type == OP_REQUIRE
+ || saveop->op_type == OP_USE))
? (EVAL_INREQUIRE | (PL_in_eval & EVAL_INEVAL))
: EVAL_INEVAL);
@@ -3028,7 +3029,8 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
PL_eval_root = NULL;
PL_curcop = &PL_compiling;
CopARYBASE_set(PL_curcop, 0);
- if (saveop && (saveop->op_type != OP_REQUIRE) && (saveop->op_flags & OPf_SPECIAL))
+ if (saveop && !(saveop->op_type == OP_REQUIRE || saveop->op_type == OP_USE)
+ && (saveop->op_flags & OPf_SPECIAL))
PL_in_eval |= EVAL_KEEPERR;
else
CLEAR_ERRSV();
@@ -3052,7 +3054,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
LEAVE; /* pp_entereval knows about this LEAVE. */
msg = SvPVx_nolen_const(ERRSV);
- if (optype == OP_REQUIRE) {
+ if (optype == OP_REQUIRE || optype == OP_USE) {
const SV * const nsv = cx->blk_eval.old_namesv;
(void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
&PL_sv_undef, 0);
@@ -3086,8 +3088,10 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
* Otherwise, propagate the context from the eval(). */
if (PL_eval_root->op_type == OP_LEAVEEVAL
&& cUNOPx(PL_eval_root)->op_first->op_type == OP_LINESEQ
- && cLISTOPx(cUNOPx(PL_eval_root)->op_first)->op_last->op_type
- == OP_REQUIRE)
+ && (cLISTOPx(cUNOPx(PL_eval_root)->op_first)->op_last->op_type
+ == OP_REQUIRE
+ || cLISTOPx(cUNOPx(PL_eval_root)->op_first)->op_last->op_type
+ == OP_USE) )
scalar(PL_eval_root);
else if ((gimme & G_WANT) == G_VOID)
scalarvoid(PL_eval_root);
@@ -3099,7 +3103,8 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
DEBUG_x(dump_eval());
/* Register with debugger: */
- if (PERLDB_INTER && saveop && saveop->op_type == OP_REQUIRE) {
+ if (PERLDB_INTER && saveop && (saveop->op_type == OP_REQUIRE
+ || saveop->op_type == OP_USE) ) {
CV * const cv = get_cvs("DB::postponed", 0);
if (cv) {
dSP;
@@ -3249,7 +3254,7 @@ PP(pp_require)
}
/* We do this only with use, not require. */
- if (PL_compcv &&
+ if ( (PL_op->op_type == OP_USE) &&
/* If we request a version >= 5.9.5, load feature.pm with the
* feature bundle that corresponds to the required version. */
vcmp(sv, sv_2mortal(upg_version(newSVnv(5.009005), FALSE))) >= 0) {
@@ -3293,7 +3298,7 @@ PP(pp_require)
unixname = (char *) name;
unixlen = len;
}
- if (PL_op->op_type == OP_REQUIRE) {
+ if (PL_op->op_type == OP_REQUIRE || PL_op->op_type == OP_USE) {
SV * const * const svp = hv_fetch(GvHVn(PL_incgv),
unixname, unixlen, 0);
if ( svp ) {
@@ -3516,7 +3521,7 @@ PP(pp_require)
CopFILE_set(&PL_compiling, tryrsfp ? tryname : name);
SvREFCNT_dec(namesv);
if (!tryrsfp) {
- if (PL_op->op_type == OP_REQUIRE) {
+ if (PL_op->op_type == OP_REQUIRE || PL_op->op_type == OP_USE) {
const char *msgstr = name;
if(errno == EMFILE) {
SV * const msg
@@ -3783,7 +3788,7 @@ PP(pp_leaveeval)
CvDEPTH(PL_compcv) = 0;
lex_end();
- if (optype == OP_REQUIRE &&
+ if ((optype == OP_REQUIRE || optype == OP_USE) &&
!(gimme == G_SCALAR ? SvTRUE(*SP) : SP > newsp))
{
/* Unassume the success we assumed earlier. */
diff --git a/pp_proto.h b/pp_proto.h
index 0c1829a..9998434 100644
--- a/pp_proto.h
+++ b/pp_proto.h
@@ -409,5 +409,6 @@ PERL_PPDEF(Perl_pp_getlogin)
PERL_PPDEF(Perl_pp_syscall)
PERL_PPDEF(Perl_pp_lock)
PERL_PPDEF(Perl_pp_once)
+PERL_PPDEF(Perl_pp_use)
/* ex: set ro: */
diff --git a/t/lib/feature/implicit b/t/lib/feature/implicit
index 0632770..6c8f508 100644
--- a/t/lib/feature/implicit
+++ b/t/lib/feature/implicit
@@ -60,3 +60,17 @@ BEGIN {
}
EXPECT
Helloworld
+########
+# VERSION requirement in BLOCK - feature is lexical
+{ use 5.9.5; }
+say "Hello", "world";
+EXPECT
+OPTION regex
+^String found where operator expected
+########
+# VERSION requirement as require - bug perl RT #69050
+BEGIN { require 5.9.5; }
+say "Hello", "world";
+EXPECT
+OPTION regex
+^String found where operator expected
--
1.6.1
|
The RT System itself - Status changed from 'new' to 'open' |
From @davidnicolOn Fri, Sep 11, 2009 at 10:11 AM, Robin Barker <Robin.Barker@npl.co.uk> wrote:
Does this mean that use MyMagicTieingModule my $VariableIntendedToBeVisibileInThisScope; will start DWIW? -- |
From zefram@fysh.orgRobin Barker wrote:
I think a better approach is: * "require 5.010" ceases to do anything other than the version check * "use 5.010" expands (in the optree) to something like That is, the feature magic goes into the parsing of the "use" instruction, -zefram |
From @briandfoyCreated by brian@mimibean.localThe feature.pm docs notes that it's implicitly loaded by -E BEGIN { require VERSION } It is not loaded with just a plain require though: require VERSION; What's the right behavior? I don't expect require ever to do Perl Info
|
From @xdg
That's a tricky question. Since "use VERSION" is effectively The relevant "if" clause in pp_ctl.c is this: if (PL_compcv && !(cUNOP->op_first->op_private & OPpCONST_NOVER)) { I don't know know enough of the guts to know how to differentiate -- David |
The RT System itself - Status changed from 'new' to 'open' |
From @briandfoyOn Tue, Jul 6, 2010 at 5:01 AM, David Golden via RT
It may be effectively the same (meaning that's what actually happens), -- |
From ben@morrow.me.ukQuoth brian.d.foy@gmail.com (brian d foy):
I quite like the idea of BEGIN { require VERSION } being a side-effect- use 5.12 (); to do the same thing, though I don't know if the parser can handle that. Ben |
From @xdgOn Tue, Jul 6, 2010 at 2:35 PM, Ben Morrow <ben@morrow.me.uk> wrote:
Not easily. It's trivial to make toke.c take it, but the way It's beyond my own skill to do quickly, but I encourage others to take -- David |
From r.m.barker@btinternet.comThis was discussed here as "perl version checks" on 8 Septermber 2009. Robin |
From zefram@fysh.orgRobin Barker wrote:
I think that would be a bad idea. Instead, the special casing that's use 5.012; should compile as BEGIN { with "require 5.012" doing only the version check. -zefram |
From @demerphqOn 8 July 2010 11:51, Zefram <zefram@fysh.org> wrote:
+1 yves -- |
From frank.wiegand@gmail.com2010/7/8 Zefram <zefram@fysh.org>:
Great! But feature.pm bundles are like ':5.12'. So it should be BEGIN { Thanks, Frank |
From @cpansproutFixed by 88e9444. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#69050 (status was 'resolved')
Searchable as RT69050$
The text was updated successfully, but these errors were encountered: