Skip Menu |
Report information
Id: 123020
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors:
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Subject: Void repeat propagates the calling context to its lhs
Download (untitled) / with headers
text/plain 657b
If x with parentheses around the lhs occurs in void context, no matter where it occurs in a sub it will propagate the context in which the sub was called: $ ./perl -lIlib -e 'sub c { print qw[void scalar list][wantarray + defined wantarray] } sub f { (c())x(c()); print "---"; } f(); $_=f(); () = f() ' void scalar --- scalar scalar --- list scalar --- That’s *weird*. But what should it do? Internally, x falls back to scalar repeat when not in list context. (It doesn’t check explicitly for scalar context.) So scalar context here would make sense. (I suspect some instances of the void context result in stack bugs.) -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
On Mon Oct 20 20:21:28 2014, sprout wrote: Show quoted text
> If x with parentheses around the lhs occurs in void context, no matter > where it occurs in a sub it will propagate the context in which the > sub was called: > > $ ./perl -lIlib -e 'sub c { print qw[void scalar list][wantarray + > defined wantarray] } sub f { (c())x(c()); print "---"; } f(); $_=f(); > () = f() ' > void > scalar > --- > scalar > scalar > --- > list > scalar > --- > > That’s *weird*. But what should it do? Internally, x falls back to > scalar repeat when not in list context. (It doesn’t check explicitly > for scalar context.) So scalar context here would make sense. (I > suspect some instances of the void context result in stack bugs.)
I was right about the stack bug, which I fixed a while ago in 3a100dabd. I have just fixed this bug for the most part in commit 1e2dd519e, by applying scalar context to the lhs if the repetition is known to be in void context at compile time. At the end of a subroutine it still exhibits the buggy behaviour. -- Father Chrysostomos


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org