Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Void repeat propagates the calling context to its lhs #14174

Open
p5pRT opened this issue Oct 21, 2014 · 3 comments
Labels

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Oct 21, 2014

Migrated from rt.perl.org#123020 (status was 'open')

Searchable as RT123020$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 21, 2014

From @cpansprout

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

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 16, 2014

From @cpansprout

On Mon Oct 20 20​:21​:28 2014, sprout wrote​:

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 3a100da.

I have just fixed this bug for the most part in commit 1e2dd51, 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

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 16, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.