Stop CORE::GLOBAL::require lookup from crashing on stub
authorFather Chrysostomos <sprout@cpan.org>
Mon, 4 Nov 2013 01:32:37 +0000 (17:32 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 4 Nov 2013 13:10:19 +0000 (05:10 -0800)
‘sub CORE::GLOBAL::require;’ doesn’t create a full glob, but cheats
for efficiency.  Compilation of require ops was not taking this
into account.

op.c
t/op/override.t

diff --git a/op.c b/op.c
index ee51a99..b1f32a4 100644 (file)
--- a/op.c
+++ b/op.c
@@ -9744,6 +9744,8 @@ Perl_ck_require(pTHX_ OP *o)
        if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) {
            GV * const * const gvp = (GV**)hv_fetchs(PL_globalstash, "require", FALSE);
            gv = gvp ? *gvp : NULL;
+           if (gv && !isGV(gv))
+               gv_init(gv, PL_globalstash, "require", 7, 0);
        }
     }
 
index 4474176..71c2ac2 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
     require 'Config_heavy.pl'; # since runperl will need them
 }
 
-plan tests => 31;
+plan tests => 32;
 
 #
 # This file tries to test builtin override using CORE::GLOBAL
@@ -159,3 +159,6 @@ is runperl(prog => 'sub CORE::GLOBAL::do; do file; print qq-ok\n-'),
 is runperl(prog => 'sub CORE::GLOBAL::glob; glob; print qq-ok\n-'),
   "ok\n",
   'no crash with CORE::GLOBAL::glob stub';
+is runperl(prog => 'sub CORE::GLOBAL::require; require re; print qq-o\n-'),
+  "o\n",
+  'no crash with CORE::GLOBAL::require stub';