develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #24684] Too late warning not given for CHECK block in INIT block

Thread Previous
From:
Father Chrysostomos via RT
Date:
January 10, 2012 13:58
Subject:
[perl #24684] Too late warning not given for CHECK block in INIT block
Message ID:
rt-3.6.HEAD-14510-1326232680-171.24684-15-0@perl.org
On Sat Dec 17 23:17:09 2011, sprout wrote:
> On Sat Dec 17 20:36:28 2011, alh wrote:
> > Thanks for the report.
> > 
> > This is because when nothing is actually happening in the main scope of
> > the program it's treated as an OP_STUB which causes Perl_newPROG() to
> > skip out before setting PL_main_start; which is what the warning
requires:
> > 
> > (Inside of Perl_newprog()):
> > 
> >          if (o->op_type == OP_STUB) {
> >             PL_comppad_name = 0;
> >             PL_compcv = 0;
> >             S_op_destroy(aTHX_ o);
> > 
> >             return; < -- Returns here
> >         }
> >         PL_main_root = op_scope(sawparens(scalarvoid(o)));
> >         PL_curcop = &PL_compiling;
> >         PL_main_start = LINKLIST(PL_main_root); < -- This is needed
> > 
> > (The warning check:)
> > 
> >                 if (PL_main_start)
> >                     Perl_ck_warner(aTHX_ packWARN(WARN_VOID),
> >                                    "Too late to run CHECK block");
> > 
> > This warns correctly for example:
> > 
> >  perl -we'INIT { eval "CHECK {print qq:in check in init\n:}" } print
> "hi";'
> > 
> > Since the CHECK blocks don't actually get run, the warning should still
> > get generated. Does PL_main_start (and PL_main_root, etc..) need to get
> > set even when it's just an OP_STUB?  Or is this an unlikely / illogical
> > situation?
> 
> It may be very unlikely, but I would not consider it illogical to want
> to eval a generated CHECK block.

On the other hand, this bug report was about the main program, not an
empty eval.  So I am apparently rather confused.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=24684

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About