Navigation Menu

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

list assignment: arrays on LHS aren't filled properly #477

Closed
p6rt opened this issue Dec 11, 2008 · 10 comments
Closed

list assignment: arrays on LHS aren't filled properly #477

p6rt opened this issue Dec 11, 2008 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Dec 11, 2008

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

Searchable as RT61300$

@p6rt
Copy link
Author

p6rt commented Dec 11, 2008

From @moritz

23​:27 < moritz_> rakudo​: my ($x, @​y) = <a b c d e>; say @​y.perl
23​:27 < p6eval> rakudo 33813​: OUTPUT["b"␤]

so @​y gets only the first element, when in fact it should get all the rest.

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

From @cspencer

When declaring one or more array variables in list syntax​:

  my (@​a, @​b);

they are not properly initialized and are left as Undef objects.
Subsequence array operations on the variable results in an error​:

  @​a.push(2);

  Method 'push' not found for invocant of class 'Undef'
  current instr.​: '_block14' pc 85 (EVAL_15​:47)
  called from Sub '!UNIT_START' pc 15711 (src/builtins/guts.pir​:327)
  called from Sub 'parrot;PCT;HLLCompiler;eval' pc 892
  (src/PCT/HLLCompiler.pir​:508)

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

From @pmichaud

On Thu, Dec 11, 2008 at 02​:28​:18PM -0800, Moritz Lenz wrote​:

23​:27 < moritz_> rakudo​: my ($x, @​y) = <a b c d e>; say @​y.perl
23​:27 < p6eval> rakudo 33813​: OUTPUT["b"␤]

so @​y gets only the first element, when in fact it should get all the rest.

The problem is that array variables in lists are being initialized to
a scalar type instead of an Array, and this causes the assignment
to fail.

This will be fixed as part of signature refactoring, coming soon.

Pm

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 20, 2008

From @moritz

Cory Spencer (via RT) wrote​:

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

When declaring one or more array variables in list syntax​:

my (@​a, @​b);

they are not properly initialized and are left as Undef objects.
Subsequence array operations on the variable results in an error​:

@​a.push(2);

Method 'push' not found for invocant of class 'Undef'
current instr.​: '_block14' pc 85 (EVAL_15​:47)
called from Sub '!UNIT_START' pc 15711 (src/builtins/guts.pir​:327)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 892
(src/PCT/HLLCompiler.pir​:508)

Added tests to t/spec/S04-declarations/my.t in (pugs) r24516.

Moritz

@p6rt
Copy link
Author

p6rt commented Dec 20, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 21, 2008

From @cspencer

Possible fix attached (though I'm nowhere near an expert on the
grammar/actions files).

On Fri Dec 19 14​:17​:03 2008, pmichaud wrote​:

On Thu, Dec 11, 2008 at 02​:28​:18PM -0800, Moritz Lenz wrote​:

23​:27 < moritz_> rakudo​: my ($x, @​y) = <a b c d e>; say @​y.perl
23​:27 < p6eval> rakudo 33813​: OUTPUT["b"␤]

so @​y gets only the first element, when in fact it should get all
the rest.

The problem is that array variables in lists are being initialized to
a scalar type instead of an Array, and this causes the assignment
to fail.

This will be fixed as part of signature refactoring, coming soon.

Pm

@p6rt
Copy link
Author

p6rt commented Dec 21, 2008

From @cspencer

variable-decl.patch
Index: src/parser/actions.pm
===================================================================
--- src/parser/actions.pm	(revision 34165)
+++ src/parser/actions.pm	(working copy)
@@ -2392,7 +2392,7 @@
                     :name($_),
                     :isdecl(1),
                     :scope($scope),
-                    :viviself('Perl6Scalar')
+                    :viviself(container_type($sigil))
                 ));
 
                 # Add block entry.

@p6rt
Copy link
Author

p6rt commented Dec 21, 2008

From @pmichaud

On Sat Dec 20 18​:48​:57 2008, cspencer wrote​:

Possible fix attached (though I'm nowhere near an expert on the
grammar/actions files).

Yes, the fix appears to work (and doesn't cause any failures); now
applied in r34184.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Dec 21, 2008

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

@p6rt p6rt closed this as completed Dec 21, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant