This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Propagate lvalue context to && and ||
authorFather Chrysostomos <sprout@cpan.org>
Thu, 24 Oct 2013 21:45:34 +0000 (14:45 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 25 Oct 2013 00:50:19 +0000 (17:50 -0700)
commit2e73d70e524ca7e5c7c5ae9b0017c31f6f6d4d9a
treecf0b833528ac703e78baf94d0e03ccf6d0e0fed6
parent447779af4ae9549587ef7522ffc6dbe70388d31e
Propagate lvalue context to && and ||

I did this for the last statement in an lvalue sub (and the argument
to ‘return’ in an lvalue sub) in commit 2ec7f6f2428.

It turns out that it needs to apply in other lvaluish contexts, too:

$ ./perl -Ilib -le 'for($a||$b){$_++} print $b'
1
$ ./perl -Ilib -le 'for(pos $a || pos $b){$_++} print pos $b'
Modification of a read-only value attempted at -e line 1.

If I can assign to $b through this construct, then why not pos?
op.c
t/op/or.t