This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #120374] Stop for($h{k}||'') from vivifying
authorFather Chrysostomos <sprout@cpan.org>
Sun, 9 Feb 2014 01:02:23 +0000 (17:02 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 9 Feb 2014 19:08:13 +0000 (11:08 -0800)
commit375879aab356d483f8e0e3d339683904de7c01a3
tree0bd1de94d0ce7d7db1427d7bfd858909a7d6a7ee
parentb9093ebe6ea97f03b6e603255746c5fb3894b88e
[perl #120374] Stop for($h{k}||'') from vivifying

Commit 2e73d70e52 broke this (made it vivify) by propagating lvalue
context to the branches of || and && (to fix another bug).  It broke
App::JobLog as a result.

Because foreach does not do defelem magic (i.e., it vivifies), this
ends up extending vivification to happen where it did not before.

Fixing foreach to do defelem magic (create ‘deferred element’ scalars,
the way sub calls do, to avoid vivifying immediately) would be another
way to fix this, but it is controversial.  See ticket #2166.

So, if either argument to || (or &&) is a vivifying op, don’t propa-
gate the lvalue context, unless this is the return value of an lvalue
sub (necessary for if/else with implicit return to work correctly in
lvalue subs).
op.c
t/op/or.t