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

if block with slurpy parameter does not receive argument #4667

Closed
p6rt opened this issue Oct 21, 2015 · 6 comments
Closed

if block with slurpy parameter does not receive argument #4667

p6rt opened this issue Oct 21, 2015 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 21, 2015

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

Searchable as RT126423$

@p6rt
Copy link
Author

p6rt commented Oct 21, 2015

From @lizmat

[23​:21​:43] <lizmat> m​: sub aa { for @​_ { .say } }; aa 42
[23​:21​:43] <+camelia> rakudo-moar 009400​: OUTPUT«42␤»
[23​:21​:55] <lizmat> m​: sub aa { if @​_ { for @​_ { .say } } }; aa 42
[23​:21​:55] <+camelia> rakudo-moar 009400​: ( no output )
[23​:22​:15] <lizmat> m​: sub aa { if @​_ { say @​_ } }; aa 42
[23​:22​:15] <+camelia> rakudo-moar 009400​: OUTPUT«[]␤»
[23​:22​:33] <lizmat> seems all wrong to me ?
[23​:24​:39] <lizmat> looks like an "if @​_" eats @​_ ?
[23​:27​:42] <grondilu> m​: { @​_ && { .say for @​_ } }(42)
[23​:27​:42] <+camelia> rakudo-moar 009400​: ( no output )
[23​:28​:09] <grondilu> m​: { @​_ && "ok" }(42)
[23​:28​:09] <+camelia> rakudo-moar 009400​: ( no output )
[23​:28​:17] <grondilu> m​: say { @​_ && "ok" }(42)
[23​:28​:18] <+camelia> rakudo-moar 009400​: OUTPUT«ok␤»
[23​:28​:35] <PerlJam> m​: sub foo { if @​_ { say "hi​: @​_[]" } }; foo 42;
[23​:28​:36] <+camelia> rakudo-moar 009400​: OUTPUT«hi​: ␤»
[23​:28​:59] <grondilu> m​: say { @​_ && @​_ }(42)
[23​:28​:59] <+camelia> rakudo-moar 009400​: OUTPUT«[42]␤»
[23​:29​:14] <PerlJam> m​: sub foo { say @​_.WHAT }; foo 42;
[23​:29​:14] <+camelia> rakudo-moar 009400​: OUTPUT«(Array)␤»
[23​:30​:01] <grondilu> m​: { @​_ && { .say for @​_ }() }(42)
[23​:30​:02] <+camelia> rakudo-moar 009400​: ( no output )
[23​:30​:09] <grondilu> m​: { @​_ && { .say for @​_ }(@​_) }(42)
[23​:30​:10] <+camelia> rakudo-moar 009400​: OUTPUT«42␤»
[23​:30​:37] grondilu stops pretending he has an idea of what's going on there
[23​:32​:05] <PerlJam> m​: sub foo { say @​_; if @​_ { say @​_ } }; foo 42;
[23​:32​:05] <+camelia> rakudo-moar 009400​: OUTPUT«[42]␤[]␤»
[23​:32​:23] <PerlJam> I think it's some kind of iterator problem.
[23​:38​:00] <PerlJam> m​: sub foo { say @​_; if @​_ { say @​_; }; say @​_ }; foo 42;
[23​:38​:00] <+camelia> rakudo-moar 009400​: OUTPUT«[42]␤[]␤[42]␤»
[23​:38​:30] <PerlJam> or ... maybe @​_ is getting bound to the if's block rather than the subs block

@p6rt
Copy link
Author

p6rt commented May 20, 2016

From @smls

Still reproducible.

Simpler test-case, comparing `for` (which works as expected) to `if`​:

  for 42 { say $^a }; # 42
  for 42 { say @​_ }; # [42]

  if 42 { say $^a_ }; # 42
  if 42 { say @​_ }; # []

So it happens even without @​_ from an outer routine interfering.

Introspection reveals that the correct signature is created though​:

  for 42 { say &?BLOCK.signature; @​_ }; # (*@​_)
  if 42 { say &?BLOCK.signature; @​_ }; # (*@​_)

The `if` block just refuses to bind its argument to that signature, for some reason...

@p6rt
Copy link
Author

p6rt commented May 20, 2016

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

@p6rt
Copy link
Author

p6rt commented May 20, 2016

From @smls

Happens with an explicitly declared slurpy, too - regardless of its name​:

  for 42 -> *@​a { say @​a }; [42]
  if 42 -> *@​a { say @​a }; []


(This is Rakudo version 2016.04-210-gc59e4dc built on MoarVM version 2016.05
implementing Perl 6.c.)

@p6rt
Copy link
Author

p6rt commented Feb 19, 2018

From @dogbert17

On Fri, 20 May 2016 14​:34​:25 -0700, smls75@​gmail.com wrote​:

Happens with an explicitly declared slurpy, too - regardless of its name​:

for 42 \-> \*@&#8203;a \{ say @&#8203;a \};  \[42\]
if  42 \-> \*@&#8203;a \{ say @&#8203;a \};  \[\]

---
(This is Rakudo version 2016.04-210-gc59e4dc built on MoarVM version 2016.05
implementing Perl 6.c.)

Fixed by Zoffix++​:

Fix​: Raku/nqp@8e7201eb64
rakudo/rakudo@dfb6d951d7
rakudo/rakudo@ef1d22f4c1

Test​: Raku/roast@aa90737df1

@p6rt p6rt closed this as completed Feb 19, 2018
@p6rt
Copy link
Author

p6rt commented Feb 19, 2018

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant