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

readonly trait being passed back to passed variable #1170

Closed
p6rt opened this issue Jul 25, 2009 · 6 comments
Closed

readonly trait being passed back to passed variable #1170

p6rt opened this issue Jul 25, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 25, 2009

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

Searchable as RT67876$

@p6rt
Copy link
Author

p6rt commented Jul 25, 2009

From @finanalyst

Output to the following

my @​a; foo(@​a);
@​a = 4,3,2;
sub foo(@​z) { bar(@​z) }
sub bar(@​x) { }

is
Cannot assign to readonly variable.

The assignment on 2nd line is causing the error.

It only occurs is @​a is used as an argument to a function, that is then
used as an argument to another function.

@p6rt
Copy link
Author

p6rt commented Jul 25, 2009

From @finanalyst

workaround​:
sub foo(@​z) { my @​xz=@​z; bar(@​xz) };

@p6rt
Copy link
Author

p6rt commented Jul 25, 2009

@finanalyst - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 25, 2009

From @kyleha

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

commit 60dbacba9162ee2fbfbe0517dd94c8a5bbb80582
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sat Jul 25 17​:17​:04 2009 +0000

  [t/spec] test for RT #​67876
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;27724 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S06-signature/passing-arrays.t b/t/spec/S06-signature/passing-arrays.t
index 5ed9901..711599f 100644
--- a/t/spec/S06-signature/passing-arrays.t
+++ b/t/spec/S06-signature/passing-arrays.t
@@ -4,7 +4,7 @@ use Test;
 # L<S06/Parameters and arguments>
 # TODO: better smart-linking
 
-plan 9;
+plan 11;
 
 {
     sub count(@a) {
@@ -53,3 +53,16 @@ plan 9;
     is(test_two_array([100,5],[20,300]), 120, 
     "Passing array references to functions accepting arrays works.");
 }
+
+# A Rakudo regression
+
+{
+    sub ro_a(@a) { };
+    sub ro_b(@a) { ro_a(@a) };
+    my @x = 1, 2, 4;
+    lives_ok { ro_b(@x) },   'can pass parameter Array on to next function';
+    #?rakudo todo 'RT 67876'
+    lives_ok { @x = 5, 6 }, '... and that did not make the caller Array ro';
+}
+
+# vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

From @moritz

Fixed by jnthn's manical magic during the merge of the 'resig2' branch.
Tests unfudged, ticket resolved.

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

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

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