This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make empty lvalue subs work correctly
authorFather Chrysostomos <sprout@cpan.org>
Wed, 1 Jun 2011 04:32:28 +0000 (21:32 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 1 Jun 2011 04:32:28 +0000 (21:32 -0700)
commit69b22cd191e9b6eff1e60a75aa38b87646cfb775
tree45a707e25fd637c2f89f7e6d318ab3512755a6c8
parent6b8305409e650748b2e6fb75634200370b69238b
Make empty lvalue subs work correctly

In perl 5.8.1 and earlier, sub{} would return @_ in list context. This
was fixed in 5.8.2 for regular subs, but not lvalue subs.

Before the syntactic restriction on return values was removed in
commit 145b2bb, there was a bug affecting compilation of empty subs
before any use statement:

$ perl5.14.0 -e 'sub foo :lvalue {}'
Can't modify stub in lvalue subroutine return at -e line 1, near "{}"
Execution of -e aborted due to compilation errors.
$ perl5.14.0 -le 'use sigtrap; sub foo :lvalue {} print "ok"'
ok

But I digress. :-)

Up to 5.14, lvalue subs were still returning @_, or, rather, the ele-
ments of @_ as separate scalars:

$ perl5.14.0 -Mre -le '(sub :lvalue {}->($a,$b))=(3,4); print "$a $b"'
Useless use of "re" pragma at -e line 0
3 4

(Not exactly useless, eh? The -Mre allows the sub to compile.)

This commit fixes that bug.
op.c
pp_hot.c
t/op/sub_lval.t