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
non-modifier form of 'if' within 'for' loop fails, while the modifier form works #1883
Comments
From pk-rakudo@kailasa.net
# this works as expected
# this fails
Thanks, |
From @pmichaudOn Sun Jun 27 14:16:46 2010, pkailasa wrote:
It now works in current Rakudo: pmichaud@plum:~/rakudo$ cat x Assigning to moritz for spectest coverage. Pm |
The RT System itself - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S04-statements/if.t commit 7dae39e04f140333b2a794ec70a4f72d4cced480 [t/spec] test for RT #76174, "if" does not break lexical aliasing of $_ in a for-loop Inline Patchdiff --git a/t/spec/S04-statements/if.t b/t/spec/S04-statements/if.t
index 561a1ca..946d3d5 100644
--- a/t/spec/S04-statements/if.t
+++ b/t/spec/S04-statements/if.t
@@ -11,7 +11,7 @@ Basic "if" tests.
# L<S04/Conditional statements>
-plan 25;
+plan 26;
my $x = 'test';
if ($x eq $x) { pass('if ($x eq $x) {} works'); } else { flunk('if ($x eq $x) {} failed'); }
@@ -156,4 +156,12 @@ if (Mu) { flunk('if (Mu) {} failed'); } else { pass('if (Mu) {} works'); }
# L<S04/Statement parsing/keywords require whitespace>
eval_dies_ok('if($x > 1) {}','keyword needs at least one whitespace after it');
+# RT #76174
+# scoping of $_ in 'if' shouldn't break aliasing
+{
+ my @a = 0, 1, 2;
+ for @a { if $_ { $_++ } };
+ is ~@a, '0 2 3', '"if" does not break lexical aliasing of $_'
+}
+
# vim: ft=perl6 |
From @moritzTest coverage ensured, closing ticket. |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#76174 (status was 'resolved')
Searchable as RT76174$
The text was updated successfully, but these errors were encountered: