Navigation Menu

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

Failure to sink values in for loops #6337

Closed
p6rt opened this issue Jun 18, 2017 · 5 comments
Closed

Failure to sink values in for loops #6337

p6rt opened this issue Jun 18, 2017 · 5 comments
Labels
Bug regression Issue did not exist previously

Comments

@p6rt
Copy link

p6rt commented Jun 18, 2017

Migrated from rt.perl.org#131593 (status was 'resolved')

Searchable as RT131593$

@p6rt
Copy link
Author

p6rt commented Jun 18, 2017

From @zoffixznet

This a two part report​:

1) It appears in some cases a for loop doesn't sink stuff. Which causes, for example, a .map call to never be evaluated​:

  <Zoffix__> m​: sub foo($?) { ^2 .map​: &say }; foo() for 1
  <camelia> rakudo-moar c252b3​: ( no output )
  <Zoffix__> m​: sub foo($?) { ^2 .map​: &say }; foo().sink for 1
  <camelia> rakudo-moar c252b3​: OUTPUT​: «0␤1␤»

2) It actually works for the case when the sub is called as .&foo​:

  <Zoffix__> c​: 2017.05,HEAD sub foo($?) { ^2 .map​: &say }; foo() for 1
  <committable6> Zoffix__, ¦2017.05,HEAD(8074966)​: «»

  <Zoffix__> c​: 2017.05,HEAD sub foo($) { ^2 .map​: &say }; .&foo for 1
  <committable6> Zoffix__, ¦2017.05​: «0␤1» ¦HEAD(8074966)​: «»

This worked since summer of 2016, however, commit 9b0b9e made it not work again.

[1] rakudo/rakudo@9b0b9ef

@p6rt
Copy link
Author

p6rt commented Jun 19, 2017

From @jnthn

On Sat, 17 Jun 2017 22​:32​:41 -0700, cpan@​zoffix.com wrote​:

This a two part report​:

1) It appears in some cases a for loop doesn't sink stuff. Which
causes, for example, a .map call to never be evaluated​:

<Zoffix__> m​: sub foo($?) { ^2 .map​: &say }; foo() for 1
<camelia> rakudo-moar c252b3​: ( no output )
<Zoffix__> m​: sub foo($?) { ^2 .map​: &say }; foo().sink for 1
<camelia> rakudo-moar c252b3​: OUTPUT​: «0␤1␤»

It turns out that if did fix this, we'd break other things. Of note, we break​:

gather {
  take $_ => (1, 2, 3).Seq for (1…3), (1, (2, (3,))).Seq;
}

Because `take` returns the taken value. S32-list/flat.t is test containing this, for what it's worth. But it'd not surprise me in the least if such behavior is relied on in the wild.

2) It actually works for the case when the sub is called as .&foo​:

<Zoffix__> c​: 2017.05,HEAD sub foo($?) { ^2 .map​: &say }; foo() for 1
<committable6> Zoffix__, ¦2017.05,HEAD(8074966)​: «»

<Zoffix__> c​: 2017.05,HEAD sub foo($) { ^2 .map​: &say }; .&foo for 1
<committable6> Zoffix__, ¦2017.05​: «0␤1» ¦HEAD(8074966)​: «»

This worked since summer of 2016, however, commit 9b0b9e made it not
work again.

It's a bit curious that it works that way, but it was easy to restore the behavior. I'm figuring this got filed because something depends on it, so I've added tests so it won't stop working again in S04-statements/for.t and S04-statement-modifiers/for.t.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jun 19, 2017

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

@p6rt
Copy link
Author

p6rt commented Jun 19, 2017

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jun 19, 2017
@p6rt
Copy link
Author

p6rt commented Jun 19, 2017

From @zoffixznet

On Mon, 19 Jun 2017 03​:09​:20 -0700, jnthn@​jnthn.net wrote​:

On Sat, 17 Jun 2017 22​:32​:41 -0700, cpan@​zoffix.com wrote​:
I'm figuring this got filed because something depends on
it

Yeah, it was found by Toaster as a regression in Concurrent​::File​::Find module.

Long live the Toaster \o/

@p6rt p6rt added Bug regression Issue did not exist previously labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug regression Issue did not exist previously
Projects
None yet
Development

No branches or pull requests

1 participant