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

if you do for in eval, you loose @_, and anything from the out #398

Closed
p6rt opened this issue Nov 8, 2008 · 8 comments
Closed

if you do for in eval, you loose @_, and anything from the out #398

p6rt opened this issue Nov 8, 2008 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Nov 8, 2008

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

Searchable as RT60408$

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

From @ilyabelikin

Hi,
I compile 32444 and November die again :(

Our test_deeply use evals, but now it`s broken, example​:

my $b = eval '
  sub {
  @​_[0].say;
  for 1 { @​_[0].perl.say }
  }';

$b("Yay"); # Yay
  # undef

Ilya

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

From @jnthn

Hi,

Note that this isn't actually anything to do with eval, as originally
filed. You see exactly the same in​:

sub b {
  @​_[0].say;
  for 1 { @​_[0].perl.say }
};
b("Yay");

Changing ticket title to reflect this (still pondering the issue though).

Jonathan

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

From @jnthn

Patrick - giving this one to you, as I think it's related to or can be
addressed in your upcoming parameter refactor.

@p6rt
Copy link
Author

p6rt commented Jun 4, 2009

From @ronaldxs

sub b {
@​_[0].say;
for 1 { @​_[0].perl.say }
};
b("Yay");

Please note that as a (likely?) related problem, the code below results
in a Null PMC error​:
sub b { { say @​_[ 0 ] } }; b(5);

The initial problem can also be reproduced with "if"

sub b {
  @​_[0].say ;
  if 1 { @​_[ 0 ].say }
}
b('Yay');

Yielding the workaround below (which prints Yay twice as expected)​:
sub b {
  my @​a = @​_;
  @​a[0].say ;
  if 1 { @​a[ 0 ].say }
}
b('Yay');

pmichaud noted​:
There's still an issue in rakudo that any use of @​_ in a block makes it
act like a parameter.

@p6rt
Copy link
Author

p6rt commented Jul 5, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/t/spec/S06-signature/positional.t

@p6rt
Copy link
Author

p6rt commented Oct 8, 2011

From @moritz

Turns out that this ticket is bogus. @​_ is a placeholder variable just
like $^a, and thus always belongs to the inner block. If you don't want
that, simply use an explicit signature with a slurpy parameter on the
outer sub.

I have corrected the tests in S06-signature/positional.t to reflect this.

@p6rt
Copy link
Author

p6rt commented Oct 16, 2011

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

@p6rt p6rt closed this as completed Oct 16, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant