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 becomes string in subroutine or method calls #397

Closed
p6rt opened this issue Nov 8, 2008 · 11 comments
Closed

Array becomes string in subroutine or method calls #397

p6rt opened this issue Nov 8, 2008 · 11 comments

Comments

@p6rt
Copy link

p6rt commented Nov 8, 2008

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

Searchable as RT60404$

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

From @ilyabelikin

Hi there,

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

This one really pesky bug :(

Ilya

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

From @pmichaud

On Sat, Nov 08, 2008 at 12​:54​:52AM -0800, Ilya Belikin wrote​:

Hi there,

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

This one really pesky bug :(

I suspect this appeared as a result of the recent updates to
container semantics. Oddly, we don't seem to have any tests
for this in the spectest suite (or if there are tests, we aren't
running them for some reason).

Pm

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 25, 2008

From @moritz

On Sat Nov 08 09​:32​:09 2008, pmichaud wrote​:

On Sat, Nov 08, 2008 at 12​:54​:52AM -0800, Ilya Belikin wrote​:

Hi there,

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

This one really pesky bug :(

I suspect this appeared as a result of the recent updates to
container semantics. Oddly, we don't seem to have any tests
for this in the spectest suite (or if there are tests, we aren't
running them for some reason).

There are now tests for that in t/spec/S06-signature/passing-arrays.t
(also added to spectest), I hope that I got them right (IMHO the counts
should be 4, 1, 3; if you disagree, feel free to correct the test)

moritz

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

From @ilyabelikin

Thank you, very much!

2008/11/26 Moritz Lenz via RT <perl6-bugs-followup@​perl.org>​:

On Sat Nov 08 09​:32​:09 2008, pmichaud wrote​:

On Sat, Nov 08, 2008 at 12​:54​:52AM -0800, Ilya Belikin wrote​:

Hi there,

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

This one really pesky bug :(

I suspect this appeared as a result of the recent updates to
container semantics. Oddly, we don't seem to have any tests
for this in the spectest suite (or if there are tests, we aren't
running them for some reason).

There are now tests for that in t/spec/S06-signature/passing-arrays.t
(also added to spectest), I hope that I got them right (IMHO the counts
should be 4, 1, 3; if you disagree, feel free to correct the test)

moritz

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

From @jnthn

On Sat Nov 08 09​:32​:09 2008, pmichaud wrote​:

On Sat, Nov 08, 2008 at 12​:54​:52AM -0800, Ilya Belikin wrote​:

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

This one really pesky bug :(

I suspect this appeared as a result of the recent updates to
container semantics.

Bang on. There's a bit of a subtlety in that when we have a parameter we
tend to wrap it in a Perl6Scalar (which we need to rename at some point
I guess, but anyways...). This inherits from ObjectRef. *But* just
because something was wrapped up in a Perl6Scalar to and enforce
readonly-ness and additional type checking doesn't mean it should have
ObjectRef semantics. Now we detect this and deref a level. Which fixes
the bug, and all other spectests go on passing, so I think it's the
right fix. Checked in as r33245.

Oddly, we don't seem to have any tests for this in the spectest
suite (or if there are tests, we aren't running them for some
reason).

I unfudged the ones moritz++ added.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Nov 26, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 27, 2008

From @pmichaud

Unfortunately I think this patch causes the following to fail​:

  sub foo($a) { 1.say for $a }

  foo((1,2,3));

The problem is that simply looking at (misnamed) Perl6Scalar and
deciding what to do is a little coarse-grained. The real problem is in
the argument binding to a scalar versus array variable.

We'll probably revisit this as part of updating parameter passing
semantics. In the meantime, reopening the ticket until the above case
is resolved also.

Pm
 

@p6rt
Copy link
Author

p6rt commented Nov 27, 2008

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

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

From @pmichaud

On Sat Nov 08 00​:54​:52 2008, ihrd wrote​:

sub foo (@​a) { 1.say for @​a }
foo((1,2,3,4)); # only one 1
foo([1,2,3,4]); # only one 1
foo( my @​a = 1,2,3 ); # only one 1

Now fixed as of r35392​:

  $ ./parrot perl6.pbc
  > sub foo(@​a) { 1.say for @​a }
  > foo((1,2,3,4));
  1
  1
  1
  1
  > foo([1,2,3,4]);
  1
  1
  1
  1
  > foo( my @​a = 1,2,3 );
  1
  1
  1
  >

Tests already exist in the suite, so closing ticket. Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

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

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