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

Two occurences of $^a in a block mess with control flow #1733

Closed
p6rt opened this issue Apr 29, 2010 · 6 comments
Closed

Two occurences of $^a in a block mess with control flow #1733

p6rt opened this issue Apr 29, 2010 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 29, 2010

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

Searchable as RT74778$

@p6rt
Copy link
Author

p6rt commented Apr 29, 2010

From @sorear

# This prints gothere ONCE
# Removing either sink expression causes the correct two prints
# rakudo e16cf4
for 1, 2 {
  $^a;
  $^a;
  say "gothere";
}

@p6rt
Copy link
Author

p6rt commented May 1, 2010

From @moritz

On Thu Apr 29 10​:17​:29 2010, stefanor@​cox.net wrote​:

# This prints gothere ONCE
# Removing either sink expression causes the correct two prints
# rakudo e16cf4
for 1, 2 {
$^a;
$^a;
say "gothere";
}

The occurrence of two $^a's adds two positional parameter to the block,
making it loop only once over a list made of two items.

So it's really a signature problem, not primarily a problem with control
flow.

@p6rt
Copy link
Author

p6rt commented May 1, 2010

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

@p6rt
Copy link
Author

p6rt commented May 2, 2010

From @jnthn

On Sat May 01 01​:09​:55 2010, moritz wrote​:

On Thu Apr 29 10​:17​:29 2010, stefanor@​cox.net wrote​:

# This prints gothere ONCE
# Removing either sink expression causes the correct two prints
# rakudo e16cf4
for 1, 2 {
$^a;
$^a;
say "gothere";
}

The occurrence of two $^a's adds two positional parameter to the block,
making it loop only once over a list made of two items.

So it's really a signature problem, not primarily a problem with control
flow.

Also an ex-problem...

for 1,2 { say $^a ~ $^a }
11
22

Given to moritz++ for spectests.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented May 8, 2010

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

@p6rt p6rt closed this as completed May 8, 2010
@p6rt
Copy link
Author

p6rt commented May 8, 2010

From @kyleha

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

commit dd19e4e30646d9098f4eccdad309f77977533d44
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sat May 8 09​:11​:56 2010 +0000

  [t/spec] test for RT #​74778, multiple occurences of $^a should count as a single parameter
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;30586 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S06-signature/positional-placeholders.t b/t/spec/S06-signature/positional-placeholders.t
index a458276..4385a07 100644
--- a/t/spec/S06-signature/positional-placeholders.t
+++ b/t/spec/S06-signature/positional-placeholders.t
@@ -1,7 +1,7 @@
 use v6;
 use Test;
 
-plan 6;
+plan 7;
 
 #L<S06/Placeholder variables/>
 
@@ -29,4 +29,13 @@ non_twigil(5);
 eval_dies_ok( ' {$foo; $^foo;}(1) ',
 'A non-twigil variable should not precede a corresponding twigil variable' );
 
+# RT #74778
+{
+    my $tracker = '';
+    for 1, 2 {
+        $tracker ~= $^a ~ $^a ~ '|';
+    }
+    is $tracker, '11|22|', 'two occurences of $^a count as one param';
+}
+
 # vim: syn=perl6

@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