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

is rw on slurpy parameters #2145

Closed
p6rt opened this issue Sep 8, 2010 · 8 comments
Closed

is rw on slurpy parameters #2145

p6rt opened this issue Sep 8, 2010 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Sep 8, 2010

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

Searchable as RT77738$

@p6rt
Copy link
Author

p6rt commented Sep 8, 2010

From jrahmeh@pyxistech.com

1. Rakudo version​:
  This is Rakudo Perl 6, version built on parrot 2.7.0 r48768

2. Code that caused the bug​:
  sub incr3 (*@​v is rw) { for @​v -> $x { $x++} }
  my ($a, $b) = (0, 0);
  incr3($a, $b);
  say "incr3​: $a, $b";

3. Output​:
  Cannot modify readonly value
  in '&infix​:<=>' at line 1
  in <anon> at line 7071​:CORE.setting
  in 'incr3' at line 1
  in main program body at line 3​:a3.1

4. Expected behavior​: Code should have compiled without any errors
  It should have produced following output​:
  incr3​: 1 1

@p6rt
Copy link
Author

p6rt commented Sep 8, 2010

From jrahmeh@pyxistech.com

1. Rakudo version​:
  This is Rakudo Perl 6, version built on parrot 2.7.0 r48768

2. Code that caused the bug​:
  sub incr1 (*@​v is rw) { @​v[0]++; @​v[1]++; }
  sub incr2 (*@​v is rw) { for @​v { $_++} }

  my ($a, $b) = (0, 0);
  incr1($a, $b);
  say "incr1​: $a, $b";

  ($a, $b) = (0, 0);
  incr2($a, $b);
  say "incr2​: $a, $b";

3. Output​:
  incr1​: 0, 0
  incr2​: 1, 1

4. Expected output​:
  incr1​: 1, 1
  incr2​: 1, 1

@p6rt
Copy link
Author

p6rt commented Sep 9, 2010

From @qiuhw

  于 2010年09月09日 03​:44, Joe Rahmeh (via RT) 写道​:

# New Ticket Created by Joe Rahmeh
# Please include the string​: [perl #​77738]
# in the subject line of all future correspondence about this issue.
#<URL​: http://rt.perl.org/rt3/Ticket/Display.html?id=77738>

1. Rakudo version​:
This is Rakudo Perl 6, version built on parrot 2.7.0 r48768

2. Code that caused the bug​:
sub incr3 (*@​v is rw) { for @​v -> $x { $x++} }
I think you should write this line as this​:
sub incr3 (*@​v is rw) { for @​v -> $x is rw { $x++ } }
my ($a, $b) = (0, 0);
incr3($a, $b);
say "incr3​: $a, $b";

3. Output​:
Cannot modify readonly value
in '&infix​:<=>' at line 1
in<anon> at line 7071​:CORE.setting
in 'incr3' at line 1
in main program body at line 3​:a3.1

4. Expected behavior​: Code should have compiled without any errors
It should have produced following output​:
incr3​: 1 1

@p6rt
Copy link
Author

p6rt commented Sep 9, 2010

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

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

From @coke

On Wed Sep 08 12​:46​:36 2010, jrahmeh@​pyxistech.com wrote​:

1. Rakudo version​:
This is Rakudo Perl 6, version built on parrot 2.7.0 r48768

2. Code that caused the bug​:
sub incr1 (*@​v is rw) { @​v[0]++; @​v[1]++; }
sub incr2 (*@​v is rw) { for @​v { $_++} }

my \($a, $b\) = \(0, 0\);
incr1\($a, $b\);
say "incr1&#8203;: $a, $b";

\($a, $b\) = \(0, 0\);
incr2\($a, $b\);
say "incr2&#8203;: $a, $b";

3. Output​:
incr1​: 0, 0
incr2​: 1, 1

4. Expected output​:
incr1​: 1, 1
incr2​: 1, 1

Current output​:

incr1​: 0, 0
incr2​: 0, 0

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

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

@p6rt
Copy link
Author

p6rt commented Oct 8, 2014

From @usev6

This works now​:

sub incr1 (*@​v is rw) { @​v[0]++; @​v[1]++; }; my ($a, $b) = (0, 0); incr1($a, $b); say "incr1​: $a, $b";
incr1​: 1, 1

sub incr2 (*@​v is rw) { for @​v { $_++} }; my ($a, $b) = (0, 0); incr2($a, $b); say "incr2​: $a, $b";
incr2​: 1, 1

sub incr3 (*@​v is rw) { for @​v -> $x is rw { $x++ } }; my ($a, $b) = (0, 0); incr3($a, $b); say "incr3​: $a, $b";
incr3​: 1, 1

sub incr3_old (*@​v is rw) { for @​v -> $x { $x++} }; my ($a, $b) = (0, 0); incr3_old($a, $b); say "incr3_old​: $a, $b";
Cannot assign to a readonly variable or a value

I added tests to S04-statements/for.t with the following commit​: Raku/roast@c58e1975f5

@p6rt
Copy link
Author

p6rt commented Oct 8, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant