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

Bogus redeclaration error when doing list assignment in an argument in Rakudo #1927

Closed
p6rt opened this issue Jul 10, 2010 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 10, 2010

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

Searchable as RT76452$

@p6rt
Copy link
Author

p6rt commented Jul 10, 2010

From @masak

<jnthn> rakudo​: sub foo(*@​x) { say @​x.elems }; my @​a = 1,2,3; foo(@​a);
<p6eval> rakudo 692aa1​: OUTPUT«3␤»
<moritz_> rakudo​: multi f(@​a) { }; multi f(*@​a) { }; f(my @​a = (1, 2, 3))
<p6eval> rakudo 692aa1​: OUTPUT«===SORRY!===␤Redeclaration of symbol @​a [...]
<jnthn> huh
<moritz_> doesn't look like a redeclaration to me
<masak> moritz_​: rakudobug?
<moritz_> masak​: yes
* masak submits rakudobug
<moritz_> rakudo​: f(my @​x = (1, 2, 3))
<p6eval> rakudo 692aa1​: OUTPUT«===SORRY!===␤Redeclaration of symbol @​x [...]
<moritz_> rakudo​: f(my @​x)
<p6eval> rakudo 692aa1​: OUTPUT«Could not find sub &f [...]
<masak> moritz_++
<masak> so it has nothing to do with multis, only with the assignment
in the argument list.
<masak> rakudo​: f(my $x = (1, 2, 3))
<p6eval> rakudo 692aa1​: OUTPUT«Could not find sub &f [...]
<moritz_> list assignment :-)
<masak> rakudo​: f(my %x = (1, 2, 3))
<p6eval> rakudo 692aa1​: OUTPUT«===SORRY!===␤Redeclaration of symbol %x [...]

@p6rt
Copy link
Author

p6rt commented Jul 18, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in at least one of these files​: t/spec/S02-literals/listquote.t, t/spec/S06-signature/defaults.t

commit e0c07d6f4b4b5f2296d16dc663070bacb38cc5de
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Jul 18 14​:40​:10 2010 +0000

  [t/spec] test for RT #​76452, list assignment in function call
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31753 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S02-literals/listquote.t b/t/spec/S02-literals/listquote.t
index abe1017..afe3421 100644
--- a/t/spec/S02-literals/listquote.t
+++ b/t/spec/S02-literals/listquote.t
@@ -92,6 +92,16 @@ eval_dies_ok '<STDIN>', '<STDIN> is disallowed';
     isa_ok @a[4], Num, '< ... 1.2e1 ...> is a Num';
 }
 
+# probably doesn't really belong here, but I don't know where else to put it
+# :(    --moritz
+
+# RT #76452
+#?rakudo skip 'RT 76452'
+{
+    sub f($x) { $x[0] };
+    is f(my @x = (1, 2, 3)), 1, 'function call with assignment to list';
+}
+
 done_testing();
 
 # vim: ft=perl6
diff --git a/t/spec/S06-signature/defaults.t b/t/spec/S06-signature/defaults.t
index 989a761..d83d80c 100644
--- a/t/spec/S06-signature/defaults.t
+++ b/t/spec/S06-signature/defaults.t
@@ -10,7 +10,7 @@ Tests assigning default values to variables of type code in sub definitions.
 
 # L<S06/Optional parameters/Default values can be calculated at run-time>
 
-plan 3;
+plan 4;
 
 sub doubler($x) { return 2 * $x }
 
@@ -31,7 +31,14 @@ package MyPack {
 
 }
 
-
 ok((MyPack::val_v), "default sub called in package namespace");
 
+
+{
+    sub default_with_list($x = (1, 2)) {
+        $x[0];
+    }
+    is default_with_list(), 1, 'can have a parcel literal as default value';
+}
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Jul 18, 2010

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

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @moritz

works now, and tested in t/spec/S04-declarations/my.t

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

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

@p6rt p6rt closed this as completed Oct 1, 2011
@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