In perl.git, the branch smoke-me/padconst has been created

<http://perl5.git.perl.org/perl.git/commitdiff/ffd41f30484d4125f0905a5234a77034ea4555ed?hp=0000000000000000000000000000000000000000>

        at  ffd41f30484d4125f0905a5234a77034ea4555ed (commit)

- Log -----------------------------------------------------------------
commit ffd41f30484d4125f0905a5234a77034ea4555ed
Author: Father Chrysostomos <[email protected]>
Date:   Wed Jul 24 11:00:08 2013 -0700

    Increase $XS::APItest::VERSION to 0.55

M       ext/XS-APItest/APItest.pm

commit 68ad818928e5626f80bbd924174a3534f80079c6
Author: Father Chrysostomos <[email protected]>
Date:   Wed Jul 24 08:39:01 2013 -0700

    Stop op freeing from interfering with sub(){42} mutability
    
    The problem is that when an OP_CONST is freed, it calls pad_swipe,
    which clears the PADTMP flag when removing the SV from the pad.  Since
    PADTMP no longer necessarily means ‘in a pad’, we shouldn’t turn
    this flag off.

M       pad.c
M       t/op/sub.t

commit c605d49371b1c535a059530bb45bc56b4858f713
Author: Father Chrysostomos <[email protected]>
Date:   Wed Jul 24 08:35:46 2013 -0700

    fresh_perl.t: Make the test for #3066 more explicit
    
    This test was added to make sure that constants don’t become undefined
    as a result of being shared between ops.
    
    What was tested, though, was a side-effect, and not the actual bug
    itself.
    
    This behaviour has changed (sub(){42} now returns a mutable val-
    ue), so this test needs to change, too.  It was only passing under
    ithreads, and only as the result of another bug, which the next com-
    mit will fix.

M       t/run/fresh_perl.t

commit 95db2f42efbd964fad28b51a66e5036ac2ccbefa
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jul 2 19:53:05 2013 -0700

    Make overloaded constants always read-only
    
    They were not read-only if the constant handler returned a shared
    hash key scalar.
    
    This was brought up in bug #109744.

M       lib/overload.t
M       op.c

commit 9f52f94cc3d8872f46bb49e08aef21ef59385f09
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jul 2 18:29:43 2013 -0700

    Don’t check IS_PADCONST in pad.c:pad_alloc
    
    Since recent commits have given constants &PL_sv_no names, this check
    is redundant, since any slots for constants will have been skipped
    over by the sv != &PL_sv_undef check just above.

M       pad.c

commit 585041f654d1061e88c99ee5b36dd9c8772b931c
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jul 2 18:25:48 2013 -0700

    pad.c: Don’t copy shared hash key targets when cloning
    
    When creating a new thread, don’t treat shared hash key targets as
    constants.  (See the previous commit for explanation.)
    
    This should cause no change in behaviour, because the new target will
    not be in use, and its next use will immediately overwrite its value.
    It just saves having to copy a string that will be overwritten.

M       pad.c

commit 954e5e49f7900d95c20ab949959d7e6569946e50
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jul 2 18:18:13 2013 -0700

    Stop shared hash key TARGs from being shared
    
    A CV has a list of pads containing a different pad for each recursion
    level.  pad_push, which adds a new pad to the list, copies some items
    from pad no. 1 but not others.  In particular op targets¹ are created
    anew, but, under ithreads, constants² are not.  Historically, these
    were distinguished from each other by flags on the value.  Any read-
    only or shared hash key scalar was considered to be a constant, and
    hence shared between pads.  The target returned by ref() is a shared
    hash key scalar, so it was being shared between recursion levels.
    Recent commits have made it possible to distinguish between constants
    and targets based on the name.  Formerly, both were nameless pad
    entries.  Now constants have zero-length names (PadnamePV(name) &&
    !PadnameLEN(name)).  So we can use that to fix this bug.
    
    ¹ Many operators return the same scalar each time, for efficiency.
      This is stored in the pad, and is known as the target, or TARG.
    ² Constanst are stored in the pad under ithreads, instead of being
      attached directly to ops, as they are under non-threaded builds.

M       pad.c
M       t/op/sub.t

commit 14a2e22d5ca02aee8bbf208cc6e8c0fd889f115d
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 30 20:26:34 2013 -0700

    [perl #79908] Stop sub inlining from breaking closures
    
    When a closure closes over a variable, it references the variable
    itself, as opposed to taking a snapshot of its value.
    
    This was broken by the constant optimisation added for
    constant.pm’s sake:
    
    {
        my $x;
        sub () { $x };  # takes a snapshot of the current value of $x
    }
    
    constant.pm no longer uses that mechanism, except on older perls, so
    we can remove this hack, causing code like this this to start work-
    ing again:
    
    BEGIN{
        my $x = 5;
        *foo = sub(){$x};
        $x = 6
    }
    print foo; # now prints 6, not 5

M       embed.fnc
M       embed.h
M       op.c
M       pad.c
M       proto.h
M       t/op/sub.t

commit 99d2533751acc79e9e4364ee5d0ccba15d45b655
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 30 14:51:37 2013 -0700

    Make sub(){42} return a mutable value
    
    But only make it do so in lvalue context.  This will be just as fast
    in true rvalue context.  In either case, it is still inlined.
    
    This makes sub () { 42 } and sub () { return 42 } do the same thing.
    
    It also means that sub () { '-'x75 } reverts back to returning a muta-
    ble value, the way it did in 5.16.  From now on, tweaks to constant
    folding will no longer affect the mutability of the return value of a
    nullary function.
    
    ‘use constant’ is unaffected.  It still returns read-only values.
    
    This was brought up in ticket #109744.

M       op.c
M       t/op/sub.t

commit ede45f06c91a287edde4837ee1465df438857057
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 30 00:40:58 2013 -0700

    Tweak optree_constants.t for inlined list consts

M       ext/B/t/optree_constants.t

commit e039fc773ecc20684172e3dd37f92a28fd2dc957
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 30 00:26:46 2013 -0700

    Update constant.pm to reflect list inlinement
    
    I also removed ‘some symbols may be redefined without generating a
    warning’.  I know not to what it refers.  It has been there as long as
    constant.pm has.  If a constant is clobbered by another constant with
    the same value, there is no warning, as it is harmless.  That may be
    to what it refers, but we don’t need a caveat for that.

M       dist/constant/lib/constant.pm

commit ac64d4fe07401d320f46ae50fc923b474f5ee4bb
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 30 00:20:33 2013 -0700

    Inline list constants
    
    These are inlined the same way as 1..5.  We have two ops:
    
      rv2av
        |
        `-- const
    
    The const op returns an AV, which is stored in the op tree, and then
    rv2av flattens it.

M       embed.fnc
M       embed.h
M       op.c
M       proto.h
M       toke.c

commit bb065d10fd30eb5b2501ef1d5d61996cdb0b54f7
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 29 23:59:48 2013 -0700

    constant.pm: Make list constants read-only
    
    Here we take advantage of the array-ref-stash-elem mechanism added in
    the previous commit, which causes the actual elements of the stored
    array to be pushed on to the stack.

M       dist/constant/lib/constant.pm
M       dist/constant/t/constant.t

commit 0b81ec4e37352eaae18dc4c1e8ec59b787a768ff
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 29 23:33:14 2013 -0700

    Allow stash elems to be array refs
    
    These turn into CVs that return the contents of the array.  Future
    commits will make constant.pm use these and also make them inlinable.
    
    Even without inlining, these subs are faster, because they are XSUBs:
    
    $ time ./perl -Ilib -e 'my @a=1..1000000; sub foo { @a } () = foo for 1..10'
    
    real        0m3.725s
    user        0m3.407s
    sys 0m0.227s
    $ time ./perl -Ilib -e 'my @a=1..1000000; BEGIN { $::{foo} = \@a } () = foo 
for 1..10'
    
    real        0m2.153s
    user        0m1.949s
    sys 0m0.121s

M       gv.c
M       op.c
M       pod/perldiag.pod
M       t/op/gv.t
M       t/uni/gv.t

commit 8c826b04409fa8029bf463dab5df94c8df5b1701
Author: Father Chrysostomos <[email protected]>
Date:   Fri Jun 28 18:25:28 2013 -0700

    Increase $constant::VERSION to 1.28

M       dist/constant/lib/constant.pm

commit bcfcab93ae8ab39ec8eca74970592e58fab80854
Author: Father Chrysostomos <[email protected]>
Date:   Fri Jun 28 01:27:48 2013 -0700

    Stop constant.pm from (ab)using subs for scalars
    
    under versions that support $::{foo} = \1.
    
    This changes no behaviour.  Future commits will change the way
    sub(){42} and sub(){$forty_two} work.  (The former will return a muta-
    ble value; the latter will not be inlined at all.)

M       dist/constant/lib/constant.pm

commit 0f1ecde5aca60059c25da9773eaa993cee2999ea
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 27 18:11:48 2013 -0700

    [perl #78194] Make re-evals copy PADTMPs
    
    So that \$_ == \$_ will be true in "$foo$bar" =~ /(?{...})/.
    
    Many ops return the same scalar each time, for efficiency; refgen (\)
    knows about that and copies them, to hide the implementation detail,
    but constructs, such as regular expression code blocks in this case,
    need to do the same thing.

M       regexec.c
M       t/re/rxcode.t

commit 991ba81cec44db5af63200891c5a8cac73076f5d
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 27 14:37:14 2013 -0700

    [perl #78194] Make sort copy PADTMPs
    
    Copy PADTMPs (op return values) when there is a sort block/sub that is
    not optimised away and we are not sorting in place, so that \$a == \$a
    will return true.
    
    Many ops return the same scalar each time, for efficiency; refgen (\)
    knows about that and copies them, to hide the implementation detail,
    but other ops (sort in this case) need to do the same thing.

M       pp_sort.c
M       t/op/sort.t

commit fa2f9f6837b9cf7f0122b31635a7f674c6cde099
Author: Father Chrysostomos <[email protected]>
Date:   Mon Jun 24 21:28:36 2013 -0700

    [perl #78194] Make x copy PADTMPs in lv cx
    
    So that \(("$a")x2) will give two references to the same scalar, the
    way that \(($a)x2) does.

M       pp.c
M       t/op/repeat.t

commit 25584d9ecb56078b741029cf119a2c861b01a66e
Author: Father Chrysostomos <[email protected]>
Date:   Mon Jun 24 20:16:30 2013 -0700

    [perl #78194] Make list slices copy PADTMPs in lv cx
    
    So that slices that reference the same value multiple times (such as
    (...)[1,1]) will exhibit referential identity (\(...)[1,1] will return
    two references to the same scalar).

M       pp.c
M       t/op/list.t

commit 6ec0e2b1f8e0a8efe6e493de0a8b72e186a3b6aa
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 23 07:08:24 2013 -0700

    Stop folding of ops from changing mutability
    
    If $a+$b produces a mutable value, then so should 1+2.

M       ext/Devel-Peek/t/Peek.t
M       op.c
M       t/comp/fold.t
M       t/op/readline.t
M       t/op/vec.t
M       t/uni/readline.t

commit f67b6eab68abde6f70d52c1d691ed43abec3cd4f
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 23 07:06:49 2013 -0700

    [perl #78194] Make foreach copy pad tmps
    
    before aliasing them to $_.
    
    This caused one to-do test in sub.t to pass, but the bug it is testing
    for has not been fixed, so I added another one.  I didn’t remove the
    to-do test that started passing, because it is still a good test to
    have (the only test we have for interactions betwen foreach, shared
    hash keys, and recursion).

M       pp_hot.c
M       t/cmd/for.t
M       t/op/sub.t

commit 15b829aee33ddca15d007ce901d6c321bb7f80b3
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 22 23:04:13 2013 -0700

    Correct list.t descr in MANIFEST
    
    We don’t use the term ‘array’ for lists any more.  Also, mention
    slices, since list slices are tested here.

M       MANIFEST

commit 5774ecdf3d3efd5e47541ee5a5bb44188dfa249a
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 22 18:46:00 2013 -0700

    [perl #3105] Make 1..3 modification safe
    
    This construct is optimised at compile time to an anonymous array with
    an implicit @{} around it if both arguments are constant.  Modifying
    elements of that array produces wrong results the next time the same
    code is executed.
    
    If we mark each element of the array as PADTMP, then it will be
    treated like an operator’s return value (which it is) and get copied
    as appropriate.

M       op.c
M       t/op/range.t
M       t/op/svleak.t

commit 56ab84551a0aa035f456715d8b707f66fd26457f
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 22 00:26:12 2013 -0700

    constant.t: Correct version
    
    I didn’t have this done in time for 5.19.1.

M       dist/constant/t/constant.t

commit 66f11721298320b7a5446de0b2a54c37bba6bbe4
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 20 14:32:15 2013 -0700

    [perl #78194] Make sub calls copy pad tmps
    
    before aliasing them to elements of @_.

M       ext/Devel-Peek/t/Peek.t
M       pp_hot.c
M       t/op/sub.t
M       t/op/tie.t

commit be7ed6311845d7c631a898db2bce73e2b2bb1d44
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 20 14:13:20 2013 -0700

    Increase $OptreeCheck::VERSION to 0.10
    
    though I still don’t understand why it has a version at all.

M       ext/B/t/OptreeCheck.pm

commit 8fb2c4717feb6671b0dec711fb6c9633f498e092
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 20 06:04:59 2013 -0700

    [perl #78194] Make grep/map copy pad tmps
    
    before aliasing them to $_.
    
    And make sure the copies go back on the stack for grep, since modi-
    fying $_ in the grep block or expression is supposed to modify the
    item returned.

M       pp_ctl.c
M       pp_hot.c
M       t/op/grep.t

commit 9a6ea2ef4b65fce15207789ec03db4154441792d
Author: Father Chrysostomos <[email protected]>
Date:   Thu Jun 20 05:25:01 2013 -0700

    pad.c: cast before comparing signed with unsigned

M       pad.c

commit 7e6afa78c0bbcf2e3b617ce2e330a1d145548bc7
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jun 18 20:34:21 2013 -0700

    op.c: Stop copying constants under ithreads
    
    This fixes bugs #21979, #89188, #109746, #114838 and #115388 and
    mostly fixes #109744 and #105906 (other issues still remain in those
    two tickets).
    
    Because the PADTMP flag was doing double duty, indicating that a
    pad slot was in use in addition to indicating a target, constants
    could not be shared between pad slots, as freeing one const op (and
    turning of its PADTMP flag in pad_free) would mark some other pad
    slot as free.
    
    I believe this may have been fixed already by change 3b1c21fabed,
    which made const ops use pad_swipe (which removes the SV from the
    pad) instead of pad_free (which marks it as available for reuse).  But
    the copying still happens.
    
    In any case, as of the previous commit, whether a pad slot for a con-
    stant is in use is now stored in the pad name.  Slots in use for const
    ops now have &PL_sv_no names.
    
    So there is no longer any reason to copy the constants.
    
    The difference can be observed thus:
    
    Before:
    
    $ ./perl -lIlib -MDevel::Peek -e 'sub foo(){42} Dump foo; Dump foo'
    SV = IV(0x7f94ea02ef10) at 0x7f94ea02ef20
      REFCNT = 2
      FLAGS = (PADTMP,IOK,READONLY,pIOK)
      IV = 42
    SV = IV(0x7f94ea02eeb0) at 0x7f94ea02eec0
      REFCNT = 1
      FLAGS = (PADTMP,IOK,READONLY,pIOK)
      IV = 42
    
    After:
    
    $ ./perl -lIlib -MDevel::Peek -e 'sub foo(){42} Dump foo; Dump foo'
    SV = IV(0x7f894882ef10) at 0x7f894882ef20
      REFCNT = 3
      FLAGS = (IOK,READONLY,pIOK)
      IV = 42
    SV = IV(0x7f894882ef10) at 0x7f894882ef20
      REFCNT = 3
      FLAGS = (IOK,READONLY,pIOK)
      IV = 42
    
    Notice the different addresses.
    
    There are still special cases for copying &PL_sv_undef, which I need
    to tackle.
    
    Since most constants created by ‘use constant’ have the PADMY flag on
    (since they reside in lexical variables inside constant.pm) and PADMY
    and PADTMP are exclusive, I have stop turning on PADTMP for constants.
    It is no longer necessary now, since before its purpose was to mark
    pad entries as being in use.  That means many to-do tests pass.

M       dist/constant/t/constant.t
M       ext/B/t/OptreeCheck.pm
M       ext/B/t/optree_constants.t
M       op.c
M       pad.c
M       t/op/not.t
M       t/op/ref.t

commit dddbcdb2ab0f101b7ac2ee3fbddc6ddca50e213d
Author: Father Chrysostomos <[email protected]>
Date:   Tue Jun 18 16:51:57 2013 -0700

    pad.c: Expand pad_push SVf_READONLY explanation

M       pad.c

commit e2a1f8849f3161be13b21d1cd72d27bba7a81cf0
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 16 14:00:01 2013 -0700

    pad.c: Use &PL_sv_no for const pad names
    
    Currently &PL_sv_undef as a pad name can indicate either a free slot
    available for use by pad_alloc or a slot used by an op target (or,
    under ithreads, a constant or GV).
    
    Currently pad_alloc distinguishes between free slots and unnamed slots
    based on whether the value in the pad has PADMY or PADTMP set.  If
    neither is set, then the slot is free.  If either is set, the slot
    is in use.
    
    This makes it rather difficult to distinguish between constants stored
    in the pad (under ithreads) and targets.  The latter need to be copied
    when referenced, to give the impression that a new scalar is being
    returned by an operator each time.  (So \"$a" has to return a refer-
    ence to a new scalar each time, but \1 should return the same one.)
    Also, constants are shared between recursion levels.  Currently, if
    the value is marked READONLY or is a shared hash key scalar, it is
    shared.  But targets can also me shared hash keys, resulting in bugs.
    
    It also makes it impossible for the same constant to be shared by mul-
    tiple pad slots, as freeing one const op will turn off the PADTMP flag
    while the other slot still uses it, making the latter appear to be
    free.  Hence a lot of copying occurs under ithreads.  (Actually, that
    may not be true any more since 3b1c21fabed, as freed const ops swipe
    their constants from the pad.  But right now, a lot of copying does
    still happen.)
    
    Also, XS modules may want to create const ops that return the same
    mutable SV each time.  That is currently not possible without
    various workarounds including custom ops and references.  (See
    <https://rt.perl.org/rt3/Ticket/Display.html?id=105906#txn-1075354>.)
    
    This commit changes pad_alloc and pad_free to use &PL_sv_no for con-
    stants and updates other code to keep all tests passing.  Subsequent
    commits will actually use that information to fix bugs.
    
    This will probably break PadWalker, but I think it is an acceptable
    trade-off.  The alternative would be to make PadnamePV forever more
    complex than necessary, by giving it a special case for &PL_sv_no and
    having it return NULL.
    
    I gave PadnameLEN a special case for &PL_sv_undef, so it may appear
    that I have simply shifted the complexity around.  But if pad names
    stop being SVs, then this exception will simply disappear, since the
    global &PL_padname_undef will have 0 in its length field.

M       ext/XS-APItest/APItest.xs
M       op.c
M       pad.c
M       pad.h
M       perl.c
M       perly.c

commit 72cbbd352951c55322424a877916f08498bab38e
Author: Father Chrysostomos <[email protected]>
Date:   Sun Jun 16 12:40:05 2013 -0700

    Re(mov|writ)e two comments from pad.c:pad_alloc
    
    The thing about "foreach" index vars was added in bbce6d697 (insepar-
    able changes from patch from perl5.003_08 to perl5.003_09, presuma-
    bly the ‘Lexical scoping cleanup’ part).  It is not valid, because
    ‘foreach’ doesn’t aliases a pad entry to a non-pad (not marked PADMY
    or PADTMP) value until run time, and pad_alloc happens at compile
    time.  The real reason we need this loop is that entries that close
    over unavailable variables are not marked PADMY.  That may have been a
    mistake, but it works because of this loop.  The reason for the loop
    also may have changed over time.
    
    The comment about copying to sv is not valid, because it is used later
    on in the same condition when compared to &PL_sv_undef.  It was added
    in commit dd2155a49b.

M       pad.c

commit 50c025e44c39a3b4920447304e857f7a0a78f83b
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 23:17:59 2013 -0700

    op.c:S_fold_constants: Add assertion
    
    This code correctly handles a value returned by a folded constant that
    is a target or a mortal.
    
    If it is neither, then it takes ownership of a reference count (with-
    out doing SvREFCNT_inc), so it ends up sharing a reference count with
    whatever owned it before.  That is only safe to do with immortals,
    which is (afaict) the only other type of scalar that can get through
    this code, so it is actually correct.
    
    Changes elsewhere could easily break this, though, so add an
    assertion.

M       op.c

commit 6412c66d75e4a86397ea2440359bf8f7f3e658e5
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 21:52:07 2013 -0700

    Change the tests for #3105 into to-dos
    
    instead of testing for the incorrect behaviour

M       t/op/range.t

commit 5acd050e6357c803af4517a646ad01bf4f426867
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 20:41:49 2013 -0700

    Test readonliness of overload constants
    
    including one to-do test

M       lib/overload.t

commit 073579ec790263db35314c0695566c87e500d50f
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 20:29:16 2013 -0700

    To-do test for #109746

M       t/op/ref.t

commit 4d0c05195212746b748c00a5e135239c794bc438
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 20:24:55 2013 -0700

    Test (im)mutability of constants and constant-like subs
    
    including many to-do tests

M       dist/constant/t/constant.t
M       t/op/sub.t

commit 86372ba765df0a1296ae760aec5acbe9a99a1f90
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 19:42:35 2013 -0700

    Test !0 and !1 immutability and singletonness
    
    The latter (for bug #114838) is a to-do test under ithreads.

M       t/op/not.t

commit 7f1b3b64bb2a920b673c439496ba0dca92d10919
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 19:29:27 2013 -0700

    Test that literal numbers and strings are read-only
    
    including ${\3}, which currently fails under ithreads (and is hence a
    to-do test).

M       t/op/ref.t

commit 0cac808c4c643e4c98b5bde1e3ee955d8f15ea29
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 19:14:14 2013 -0700

    To-do tests for perl #78194
    
    plus a regular (not to-do) test for an lvalue sub case that already
    works properly.

M       t/cmd/for.t
M       t/op/grep.t
M       t/op/list.t
M       t/op/repeat.t
M       t/op/sort.t
M       t/op/sub.t
M       t/op/sub_lval.t
M       t/op/tie.t
M       t/re/rxcode.t

commit 8ca191cba2b2ee227b953a43de120fcb999c2eec
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 11:57:56 2013 -0700

    ref.t: To-do test for retvals of folded ops

M       t/comp/fold.t

commit e0dbdd011e3a661f84b66bef78cc60975543c702
Author: Father Chrysostomos <[email protected]>
Date:   Sat Jun 15 11:41:57 2013 -0700

    sub.t: To-do test for recursive shared-hash-keys TARGs
    
    This is only buggy under ithreads.
    
    sub a {
      for (${\""}.${\""}) {
        $_ = $_[0] || __PACKAGE__;
        print "$_\n";
        a("road") unless $_[0];
        print "$_\n";
      }
    }
    a();
    
    The outer call sets the scalar returned by ${\""}.${\""} to the cur-
    rent package name.
    
    The inner call sets it to "road".
    
    Each call prints it twice, the outer call surrounding the inner call.
    The output in 5.10-5.18 is:
    
    main
    road
    road
    road
    
    because the inner call is clobbering the same scalar.  If __PACKAGE__
    is changed to "main", it works, and prints
    
    main
    road
    road
    main
    
    (as the script above also prints in 5.8.8).

M       t/op/sub.t
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to