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

Array.clone does not return a properly independent array #5706

Closed
p6rt opened this issue Sep 29, 2016 · 4 comments
Closed

Array.clone does not return a properly independent array #5706

p6rt opened this issue Sep 29, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Sep 29, 2016

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

Searchable as RT129762$

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 29, 2016

From @smls

Calling .clone on an Array returns a new Array object, but (even
shallow) changes to one affect the other​:

  my $a = [2, 4, 6];
  my $b = @​a.clone;
  say $a.WHICH; # Array|68924240
  say $b.WHICH; # Array|68924304
  @​a.push(8);
  dd $a; # Array $a = $[2, 4, 6, 8]
  dd $b; # Array $b = $[2, 4, 6, 8]

IRC comments​:

  <jnthn> An Array is an object, with a bunch of attributes, once of
which is the actual storage.
  <jnthn> I'm guessing Array doesn't have a method clone of its own,
so it does The Default Thing in Mu
  <jnthn> Which keeps the storage
  <jnthn> It should probably get its own method clone
  <jnthn> I thought that had already happened. :
  <jnthn> :S
  <jnthn> But yeah, it wants fixing. The current behavior is crap.
  <timotimo> cue writing spec tests for .clone of pretty much every
single class :)

Loading

@p6rt
Copy link
Author

@p6rt p6rt commented Feb 16, 2017

From @zoffixznet

Thank you for the report. This is now fixed​:

Rakudo fix​:
rakudo/rakudo@dc69daf
rakudo/rakudo@11d005e
rakudo/rakudo@4b85db6

Tests​:
Raku/roast@a460cdc
Raku/roast@ea5cc0d

Loading

@p6rt
Copy link
Author

@p6rt p6rt commented Feb 16, 2017

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

Loading

@p6rt p6rt closed this Feb 16, 2017
@p6rt
Copy link
Author

@p6rt p6rt commented Feb 16, 2017

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

Loading

@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant