This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test for OPpCONST_NOVER only on OP_CONST ops.
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 27 Sep 2005 07:42:52 +0000 (07:42 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 27 Sep 2005 07:42:52 +0000 (07:42 +0000)
Plus a regression test by Schwern.

p4raw-id: //depot/perl@25611

pp_ctl.c
t/op/override.t

index 12e49ec..f817720 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3113,7 +3113,7 @@ PP(pp_require)
        sv = new_version(sv);
        if (!sv_derived_from(PL_patchlevel, "version"))
            (void *)upg_version(PL_patchlevel);
-       if (cUNOP->op_first->op_private & OPpCONST_NOVER) {
+       if (cUNOP->op_first->op_type == OP_CONST && cUNOP->op_first->op_private & OPpCONST_NOVER) {
            if ( vcmp(sv,PL_patchlevel) < 0 )
                DIE(aTHX_ "Perls since %"SVf" too modern--this is %"SVf", stopped",
                    vnormal(sv), vnormal(PL_patchlevel));
index a06677e..9cbd573 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 21;
+plan tests => 22;
 
 #
 # This file tries to test builtin override using CORE::GLOBAL
@@ -73,10 +73,12 @@ is( <$pad_fh>       , 14 );
 
 # Non-global readline() override
 BEGIN { *Rgs::readline = sub (;*) { --$r }; }
-package Rgs;
-::is( <FH>     , 13 );
-::is( <$fh>    , 12 );
-::is( <$pad_fh>        , 11 );
+{
+    package Rgs;
+    ::is( <FH> , 13 );
+    ::is( <$fh>        , 12 );
+    ::is( <$pad_fh>    , 11 );
+}
 
 # Verify that the parsing of overriden keywords isn't messed up
 # by the indirect object notation
@@ -91,7 +93,20 @@ package Rgs;
     warn OverridenWarn->foo();
 }
 BEGIN { *OverridenPop::pop = sub { ::is( $_[0][0], "ok" ) }; }
-package OverridenPop;
-sub foo { [ "ok" ] }
-pop( OverridenPop->foo() );
-pop OverridenPop->foo();
+{
+    package OverridenPop;
+    sub foo { [ "ok" ] }
+    pop( OverridenPop->foo() );
+    pop OverridenPop->foo();
+}
+
+{
+    eval {
+        local *CORE::GLOBAL::require = sub {
+            CORE::require($_[0]);
+        };
+        require 5;
+        require Text::ParseWords;
+    };
+    is $@, '';
+}