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

Rakudo still promotes List to Array when assigning to a scalar variable #1037

Closed
p6rt opened this issue Jun 4, 2009 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 4, 2009

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

Searchable as RT66304$

@p6rt
Copy link
Author

p6rt commented Jun 4, 2009

From @masak

<dakkar> rakudo​: constant $ARR = (1,2,3,4);$ARR[1]=4;say $ARR
<p6eval> rakudo 77db80​: OUTPUT«1 4 3 4␤»
<Matt-W> that seems... buggy
<jnthn> aye
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Jun 4, 2009

From @masak

<DanielC> rakudo​: my $a = (1,3,4); $a[1] = 8; # BAH!
<p6eval> rakudo 10a9b2​: ( no output )
<masak> hm.
<DanielC> pmichaud​: So, Rakudo should yell at me but doesn't.
<masak> might that be something worth reporting?
<pmichaud> masak​: you can report it, yes, but it's a very well known
bug at the moment, at least to me.
* masak submits rakudobug
<masak> better to have duplicates in RT than bad coverage.
<DanielC> rakudo​: my $b = 5; my $a = (1, $b, 3); $a[1] = 2; say $b; # 2 ?
<p6eval> rakudo 10a9b2​: OUTPUT«5␤»
<pmichaud> I think rakudo may be wrong there also.
<masak> I'll include that one.
<pmichaud> (for the same reason -- it mistakenly promotes the List to
an Array, per the earlier spec)

@p6rt
Copy link
Author

p6rt commented Nov 4, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S02-builtin_data_types/lists.t

commit f875d2ccaeddf929238237855d0f0cc57ec5a1e6
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Wed Nov 4 20​:55​:10 2009 +0000

  [t/spec] Test for RT #​66304​: list promoted to array when assigned to scalar
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28986 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S02-builtin_data_types/lists.t b/t/spec/S02-builtin_data_types/lists.t
index f8fdf0d..6eda0bb 100644
--- a/t/spec/S02-builtin_data_types/lists.t
+++ b/t/spec/S02-builtin_data_types/lists.t
@@ -7,7 +7,7 @@ use Test;
 # for this test. See
 # L<"http://www.nntp.perl.org/group/perl.perl6.language/22924">
 
-plan 21;
+plan *;
 
 # Indexing lists
 {
@@ -144,4 +144,23 @@ plan 21;
     is <1 2 3>.rt62836_x, 62836, 'call user-declared method in List:: class';
 }
 
+# RT #66304
+{
+    my $rt66304 = (1, 2, 4);
+    isa_ok $rt66304, List, 'List assigned to scalar is-a List';
+    #?rakudo 3 todo 'RT 66304'
+    is( $rt66304.WHAT, (1, 2, 4).WHAT,
+        'List.WHAT is the same as .WHAT of list assigned to scalar' );
+    dies_ok { $rt66304[1] = 'ro' }, 'literal List element is immutable';
+    is $rt66304, (1, 2, 4), 'List is not changed by attempted assignment';
+    
+    my $x = 44;
+    $rt66304 = ( 11, $x, 22 );
+    lives_ok { $rt66304[1] = 'rw' }, 'variable List element is mutable';
+    #?rakudo todo 'RT 66304'
+    is $x, 'rw', 'variable changed via assignment to list element';
+}
+
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Nov 4, 2009

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

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @moritz

now stores an immutable Seq, tests are in array-ref.t

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

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

@p6rt p6rt closed this as completed Mar 9, 2010
@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