FAQ

On Tue, 24 Sep 2002 18:08:56 -0700, sthoenna@efn.org wrote:
On Tue, 24 Sep 2002 01:58:00 +0100, hv@crypt.org wrote:
Yes; I suspect the list context is propagated too early, and the void
context fails to make it through to an already list()'d op.

Are you planning to look into fixing this?
I looked into fixing it, but op.c is somewhat too undercommented
for me to make out what needs to be done.
Looks like list context is propagated too early in *two* places.
Commenting out both fixes the problem, but it seems like it could have
negative effects. Surely those list() calls are there for a reason?
More advice appreciated.

--- op.c.orig Mon Sep 30 13:13:28 2002
+++ op.c Mon Sep 30 14:46:20 2002
@@ -2146,10 +2146,10 @@ Perl_my_attrs(pTHX_ OP *o, OP *attrs)
OP *rops = Nullop;
int maybe_scalar = 0;

- if (o->op_flags & OPf_PARENS)
+/* if (o->op_flags & OPf_PARENS)
list(o);
else
- maybe_scalar = 1;
+*/ maybe_scalar = 1;
if (attrs)
SAVEFREEOP(attrs);
o = my_kid(o, attrs, &rops);
@@ -2381,7 +2381,7 @@ OP *
Perl_localize(pTHX_ OP *o, I32 lex)
{
if (o->op_flags & OPf_PARENS)
- list(o);
+/* list(o)*/;
else {
if (ckWARN(WARN_PARENTHESIS)
&& PL_bufptr > PL_oldbufptr && PL_bufptr[-1] == ',')
End of Patch.

Search Discussions

  • Hv at Oct 1, 2002 at 10:02 am
    Yitzchak Scott-Thoennes wrote:
    :>I looked into fixing it, but op.c is somewhat too undercommented
    :>for me to make out what needs to be done.

    Well yes, that's one of the problems. :)

    :Looks like list context is propagated too early in *two* places.
    :Commenting out both fixes the problem, but it seems like it could have
    :negative effects. Surely those list() calls are there for a reason?
    :More advice appreciated.

    It doesn't break any tests, which is an interesting signal. I've applied
    a slightly more verbose form of this patch (as below) for now, as #17949;
    this does at least fix the performance bug originally reported, but let's
    keep an eye out for anything else it might affect.

    Hugo
    ==== //depot/perl/op.c#517 - /src/hv/perl/op.c ====
    @@ -2146,10 +2146,16 @@
    OP *rops = Nullop;
    int maybe_scalar = 0;

    +/* [perl #17376]: this appears to be premature, and results in code such as
    + C< my(%x); > executing in list mode rather than void mode */
    +#if 0
    if (o->op_flags & OPf_PARENS)
    list(o);
    else
    maybe_scalar = 1;
    +#else
    + maybe_scalar = 1;
    +#endif
    if (attrs)
    SAVEFREEOP(attrs);
    o = my_kid(o, attrs, &rops);
    @@ -2381,7 +2387,13 @@
    Perl_localize(pTHX_ OP *o, I32 lex)
    {
    if (o->op_flags & OPf_PARENS)
    +/* [perl #17376]: this appears to be premature, and results in code such as
    + C< our(%x); > executing in list mode rather than void mode */
    +#if 0
    list(o);
    +#else
    + ;
    +#endif
    else {
    if (ckWARN(WARN_PARENTHESIS)
    && PL_bufptr > PL_oldbufptr && PL_bufptr[-1] == ',')
  • Hv at Oct 1, 2002 at 10:09 am
    hv@crypt.org wrote:
    ::Looks like list context is propagated too early in *two* places.
    ::Commenting out both fixes the problem, but it seems like it could have
    ::negative effects. Surely those list() calls are there for a reason?
    ::More advice appreciated.
    :
    :It doesn't break any tests, which is an interesting signal.

    Additionally, I notice that with this patch the C< our(%x) > TODO test
    passes, but the C< our @x > and C< our(@x) > tests still fail.

    Hugo
  • Yitzchak Scott-Thoennes at Oct 1, 2002 at 10:02 pm

    On Tue, 01 Oct 2002 11:09:24 +0100, hv@crypt.org wrote:
    hv@crypt.org wrote:
    ::Looks like list context is propagated too early in *two* places.
    ::Commenting out both fixes the problem, but it seems like it could have
    ::negative effects. Surely those list() calls are there for a reason?
    ::More advice appreciated.
    :
    :It doesn't break any tests, which is an interesting signal.

    Additionally, I notice that with this patch the C< our(%x) > TODO test
    passes, but the C< our @x > and C< our(@x) > tests still fail.
    Patch below should fix that. rv2hv would need similar treatment if
    it's scalar code did anything that invoked a tie method. That leads
    me to notice the following bug which I will try to deal with later:

    ~ $perl -MTie::Hash -wle'tie %x,"Tie::StdHash"; %x=1..2; print(%x?"ok":"not ok")'
    not ok

    Alternatively, rv2?v in void context should be optimized away (in
    scalarvoid()?). I took a stab at doing this but couldn't get it quite
    right.

    --- perl/pp_hot.c.orig Thu Aug 22 16:01:00 2002
    +++ perl/pp_hot.c Mon Sep 30 18:08:22 2002
    @@ -780,7 +780,7 @@ PP(pp_rv2av)
    }
    SP += maxarg;
    }
    - else {
    + else if (GIMME_V == G_SCALAR) {
    dTARGET;
    I32 maxarg = AvFILL(av) + 1;
    SETi(maxarg);
    --- perl/t/comp/our.t.orig Mon Sep 30 18:25:44 2002
    +++ perl/t/comp/our.t Mon Sep 30 18:26:46 2002
    @@ -33,17 +33,18 @@

    {our $x;}
    is(TieAll->calls, '', 'our $x has no runtime effect');
    +
    {our ($x);}
    is(TieAll->calls, '', 'our ($x) has no runtime effect');
    +
    {our %x;}
    is(TieAll->calls, '', 'our %x has no runtime effect');

    -{
    - local $TODO = 'perl #17376';
    - {our (%x);}
    - is(TieAll->calls, '', 'our (%x) has no runtime effect');
    - {our @x;}
    - is(TieAll->calls, '', 'our @x has no runtime effect');
    - {our (@x);}
    - is(TieAll->calls, '', 'our (@x) has no runtime effect');
    -}
    +{our (%x);}
    +is(TieAll->calls, '', 'our (%x) has no runtime effect');
    +
    +{our @x;}
    +is(TieAll->calls, '', 'our @x has no runtime effect');
    +
    +{our (@x);}
    +is(TieAll->calls, '', 'our (@x) has no runtime effect');
    --- perl/op.c.orig Tue Oct 1 09:46:44 2002
    +++ perl/op.c Tue Oct 1 09:52:02 2002
    @@ -2147,7 +2147,7 @@
    int maybe_scalar = 0;

    /* [perl #17376]: this appears to be premature, and results in code such as
    - C< my(%x); > executing in list mode rather than void mode */
    + C< our(%x); > executing in list mode rather than void mode */
    #if 0
    if (o->op_flags & OPf_PARENS)
    list(o);
    End of Patch.
  • Hv at Oct 2, 2002 at 3:25 pm
    Yitzchak Scott-Thoennes wrote:
    :On Tue, 01 Oct 2002 11:09:24 +0100, hv@crypt.org wrote:
    :>Additionally, I notice that with this patch the C< our(%x) > TODO test
    :>passes, but the C< our @x > and C< our(@x) > tests still fail.
    :
    :Patch below should fix that.

    Thanks, applied as #17963.

    Hugo

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedOct 1, '02 at 12:02a
activeOct 2, '02 at 3:25p
posts5
users2
websiteperl.org

2 users in discussion

Hv: 3 posts Yitzchak Scott-Thoennes: 2 posts

People

Translate

site design / logo © 2022 Grokbase