Skip Menu |

This queue is for tickets about the Lexical-Var CPAN distribution.

Report information
The Basics
Id: 80309
Status: resolved
Priority: 0/
Queue: Lexical-Var

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Broken by bleadperl v5.17.3-44-g7261499 and v5.17.4-78-g85ffec3
I have tried patching the module, but the attached patch does not work. It produces errors like this: t/array_ident.t ... 1/9 # Failed test at t/array_ident.t line 24. # got: 'Global symbol "@foo" requires explicit package name at (eval 4) line 3. # Global symbol "@foo" requires explicit package name at (eval 4) line 4. # ' # expected: '' WARNING: Use of uninitialized value $aref in numeric eq (==) at t/array_ident.t line 25. I haven’t yet figured out what Lexical::Var is doing with pads.
Subject: failed patch.txt
diff -rup Lexical-Var-0.007-3v0GRj/lib/Lexical/Var.xs Lexical-Var-0.007-uRRqJL/lib/Lexical/Var.xs --- Lexical-Var-0.007-3v0GRj/lib/Lexical/Var.xs 2012-02-04 00:58:09.000000000 -0800 +++ Lexical-Var-0.007-uRRqJL/lib/Lexical/Var.xs 2012-10-20 22:08:22.000000000 -0700 @@ -83,6 +83,35 @@ static SV *THX_newSV_type(pTHX_ svtype t # define GV_NOTQUAL 0 #endif /* !GV_NOTQUAL */ +#ifndef PadARRAY +typedef AV PADNAMELIST; +typedef SV PADNAME; +# if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION) +typedef AV PADLIST; +typedef AV PAD; +# endif +# define PadlistARRAY(pl) ((PAD **)AvARRAY(pl)) +# define PadlistMAX(pl) AvFILLp(pl) +# define PadlistNAMES(pl) (*PadlistARRAY(pl)) +# define PadlistNAMESARRAY(pl) AvARRAY(*PadlistARRAY(pl)) +# define PadlistNAMESMAX(pl) AvFILLp(*PadlistARRAY(pl)) +# define PadnamelistARRAY(pnl) ((PADNAME **)AvARRAY(pnl)) +# define PadnamelistMAX(pnl) AvFILLp(pnl) +# define PadARRAY AvARRAY +# define PadMAX AvFILLp +# define PadnameIsOUR(pn) !!(SvFLAGS(pn) & SVpad_OUR) +# define PadnameLEN(pn) SvCUR(pn) +# define PadnameOURSTASH(pn) SvOURSTASH(pn) +# define PadnameOUTER(pn) !!SvFAKE(pn) +# define PadnamePV(pn) (SvPOKp(pn) ? SvPVX(pn) : NULL) +# ifdef SvPAD_STATE +# define PadnameSTATE(pn) SvPAD_STATE(pn) +# else +# define PadnameSTATE(pn) 0 +# endif +# define PadnameSV(pn) pn +#endif + /* * scalar classification * @@ -413,9 +442,10 @@ static U32 THX_pad_max(pTHX) static CV *THX_find_compcv(pTHX_ char const *vari_word) { GV *compgv; - CV *compcv; + CV *compcv = PL_compcv; /* - * Given that we're being invoked from a BEGIN block, + * We're being invoked from a BEGIN block. In perl 5.17.4 + * and earlier, * PL_compcv here doesn't actually point to the sub * being compiled. Instead it points to the BEGIN block. * The code that we want to affect is the parent of that. @@ -424,10 +454,13 @@ static CV *THX_find_compcv(pTHX_ char co * runtime, or it can be non-null in a couple of * other situations (require, string eval). */ - if(!(PL_compcv && CvSPECIAL(PL_compcv) && - (compgv = CvGV(PL_compcv)) && + if(!(compcv && +#if !PERL_VERSION_GE(5,17,5) + CvSPECIAL(compcv) && + (compgv = CvGV(compcv)) && strEQ(GvNAME(compgv), "BEGIN") && - (compcv = CvOUTSIDE(PL_compcv)) && + (compcv = CvOUTSIDE(compcv)) && +#endif CvPADLIST(compcv))) croak("can't set up lexical %s outside compilation", vari_word); @@ -437,9 +470,9 @@ static CV *THX_find_compcv(pTHX_ char co #define setup_pad(compcv, name) THX_setup_pad(aTHX_ compcv, name) static void THX_setup_pad(pTHX_ CV *compcv, char const *name) { - AV *padlist = CvPADLIST(compcv); - AV *padname = (AV*)*av_fetch(padlist, 0, 0); - AV *padvar = (AV*)*av_fetch(padlist, 1, 0); + PADLIST *padlist = CvPADLIST(compcv); + PADNAMELIST *padname = PadlistNAMES(padlist); + PAD *padvar = *PadlistARRAY(padlist); PADOFFSET ouroffset; SV *ourname, *ourvar; HV *stash;
On Sun Oct 21 02:07:28 2012, SPROUT wrote: Show quoted text
> I have tried patching the module, but the attached patch does not > work. It produces errors like > this: > > t/array_ident.t ... 1/9 > # Failed test at t/array_ident.t line 24. > # got: 'Global symbol "@foo" requires explicit package name > at (eval 4) line 3. > # Global symbol "@foo" requires explicit package name at (eval 4) line > 4. > # ' > # expected: '' > WARNING: Use of uninitialized value $aref in numeric eq (==) at > t/array_ident.t line 25. > > I haven’t yet figured out what Lexical::Var is doing with pads.
My patch had a stupid typo in it, which explains why it didn’t work. Here is a better one. I left the av_fetch calls in place for now, since perl currently has no pad-specific API for what Lexical::Var is doing. That means if pads and pad name lists stop being AVs some day this module will break again.
Subject: better patch.txt
diff -rup Lexical-Var-0.007-F6v6iu/lib/Lexical/Var.xs Lexical-Var-0.007-uRRqJL/lib/Lexical/Var.xs --- Lexical-Var-0.007-F6v6iu/lib/Lexical/Var.xs 2012-02-04 00:58:09.000000000 -0800 +++ Lexical-Var-0.007-uRRqJL/lib/Lexical/Var.xs 2012-10-21 07:03:18.000000000 -0700 @@ -83,6 +83,18 @@ static SV *THX_newSV_type(pTHX_ svtype t # define GV_NOTQUAL 0 #endif /* !GV_NOTQUAL */ +#ifndef PadARRAY +typedef AV PADNAMELIST; +# if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION) +typedef AV PADLIST; +typedef AV PAD; +# endif +# define PadlistARRAY(pl) ((PAD **)AvARRAY(pl)) +# define PadlistNAMES(pl) (*PadlistARRAY(pl)) +# define PadARRAY AvARRAY +# define PadMAX AvFILLp +#endif + /* * scalar classification * @@ -413,9 +425,10 @@ static U32 THX_pad_max(pTHX) static CV *THX_find_compcv(pTHX_ char const *vari_word) { GV *compgv; - CV *compcv; + CV *compcv = PL_compcv; /* - * Given that we're being invoked from a BEGIN block, + * We're being invoked from a BEGIN + * block. In perl 5.17.4 and earlier, * PL_compcv here doesn't actually point to the sub * being compiled. Instead it points to the BEGIN block. * The code that we want to affect is the parent of that. @@ -424,10 +437,13 @@ static CV *THX_find_compcv(pTHX_ char co * runtime, or it can be non-null in a couple of * other situations (require, string eval). */ - if(!(PL_compcv && CvSPECIAL(PL_compcv) && - (compgv = CvGV(PL_compcv)) && + if(!(compcv && +#if !PERL_VERSION_GE(5,17,5) + CvSPECIAL(compcv) && + (compgv = CvGV(compcv)) && strEQ(GvNAME(compgv), "BEGIN") && - (compcv = CvOUTSIDE(PL_compcv)) && + (compcv = CvOUTSIDE(compcv)) && +#endif CvPADLIST(compcv))) croak("can't set up lexical %s outside compilation", vari_word); @@ -437,15 +453,15 @@ static CV *THX_find_compcv(pTHX_ char co #define setup_pad(compcv, name) THX_setup_pad(aTHX_ compcv, name) static void THX_setup_pad(pTHX_ CV *compcv, char const *name) { - AV *padlist = CvPADLIST(compcv); - AV *padname = (AV*)*av_fetch(padlist, 0, 0); - AV *padvar = (AV*)*av_fetch(padlist, 1, 0); + PADLIST *padlist = CvPADLIST(compcv); + PADNAMELIST *padname = PadlistNAMES(padlist); + PAD *padvar = PadlistARRAY(padlist)[1]; PADOFFSET ouroffset; SV *ourname, *ourvar; HV *stash; - ourvar = *av_fetch(padvar, AvFILLp(padvar) + 1, 1); + ourvar = *av_fetch(padvar, PadMAX(padvar) + 1, 1); SvPADMY_on(ourvar); - ouroffset = AvFILLp(padvar); + ouroffset = PadMAX(padvar); ourname = newSV_type(SVt_PADNAME); sv_setpv(ourname, name); SvPAD_OUR_on(ourname);
Fixed in Lexical-Var-0.008, now on CPAN.