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

op.c
t/op/override.t

diff --git a/op.c b/op.c
index 40df34a..ee917b4 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5478,6 +5478,7 @@ Perl_dofile(pTHX_ OP *term, I32 force_builtin)
        if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) {
            GV * const * const gvp = (GV**)hv_fetchs(PL_globalstash, "do", FALSE);
            gv = gvp ? *gvp : NULL;
+           if (gv && !isGV(gv)) gv_init(gv, PL_globalstash, "do", 2, 0);
        }
     }
 
index 90510dd..16aec74 100644 (file)
@@ -4,9 +4,11 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
+    require Config; # load these before we mess with *CORE::GLOBAL::require
+    require 'Config_heavy.pl'; # since runperl will need them
 }
 
-plan tests => 29;
+plan tests => 30;
 
 #
 # This file tries to test builtin override using CORE::GLOBAL
@@ -150,3 +152,7 @@ BEGIN { package other; *::caller = \&::caller }
 sub caller() { 42 }
 caller; # inline the constant
 is caller, 42, 'constant inlining does not undo "use subs" on keywords';
+
+is runperl(prog => 'sub CORE::GLOBAL::do; do file; print qq-ok\n-'),
+  "ok\n",
+  'no crash with CORE::GLOBAL::do stub';