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

hash becomes string or int #469

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

hash becomes string or int #469

p6rt opened this issue Dec 8, 2008 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Dec 8, 2008

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

Searchable as RT61172$

@p6rt
Copy link
Author

p6rt commented Dec 8, 2008

From @ilyabelikin

Hi!
in 33622​:

sub foo (%h) { say %h.perl }; foo({a=>1});
{"a" => 1}
sub foo (%h) { say %h.perl }; foo(1);
1
sub foo (%h) { say %h.perl }; foo("a");
"a"

ihrd

@p6rt
Copy link
Author

p6rt commented Dec 9, 2008

From @moritz

On Mon Dec 08 10​:24​:33 2008, ihrd wrote​:

Hi!
in 33622​:

sub foo (%h) { say %h.perl }; foo({a=>1});
{"a" => 1}
sub foo (%h) { say %h.perl }; foo(1);
1
sub foo (%h) { say %h.perl }; foo("a");
"a"

Added tests to t/spec/S06-signature/passing-arrays.t.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Dec 9, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 29, 2008

From @ilyabelikin

Hi there!

examples​:

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo( { b => 2 } );
{"a" => 1, "b" => 2} # :)

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo( { } );
{"a" => 1} # :)

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo();
Odd number of elements found where hash expected # :(

say {a => 1, undef }.perl.say
Odd number of elements found where hash expected # :|

some suggestions from #perl6​:

(22​:11​:28) ruoso​: the question is whether an undefined hash shouldn't
behave as an empty hash

(22​:12​:17) avar​: I think an empty has is the empty list in that
context, not undef
(22​:12​:24) avar​: anyway, anything else would be silly

ihrd

@p6rt
Copy link
Author

p6rt commented Dec 30, 2008

From @pmichaud

On Mon Dec 08 10​:24​:33 2008, ihrd wrote​:

Hi!
in 33622​:

sub foo (%h) { say %h.perl }; foo({a=>1});
{"a" => 1}
sub foo (%h) { say %h.perl }; foo(1);
1
sub foo (%h) { say %h.perl }; foo("a");
"a"

This is a problem with parameter passing of arrays and hashes in general
-- the parameter takes on the type of its argument regardless of the
sigil. This has been fixed in the rvar branch and should be merged into
trunk soon.

Pm

@p6rt
Copy link
Author

p6rt commented Dec 30, 2008

From @pmichaud

On Mon Dec 29 04​:25​:51 2008, ihrd wrote​:

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo( { b => 2 } );
{"a" => 1, "b" => 2} # :)

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo( { } );
{"a" => 1} # :)

sub foo (%h?) { { a => 1, %h }.perl.say; }; foo();
Odd number of elements found where hash expected # :(

These are the same issues as RT #​61172 -- merging tickets.

Pm

@p6rt
Copy link
Author

p6rt commented Dec 30, 2008

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

@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

From @pmichaud

Now fixed in r35397​:

  $ ./parrot perl6.pbc
  > sub foo(%h?) { { a => 1, %h }.perl.say; };
  > foo( { b => 2 } );
  {"a" => 1, "b" => 2}
  > foo( { } );
  {"a" => 1}
  > foo( );
  {"a" => 1}
  >

We need tests for optional array and hash parameters in the test suite,
so assigning ticket to moritz. Thanks!

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

From @pmichaud

Now fixed in r35397​:

  $ ./parrot perl6.pbc
  > sub foo(%h?) { { a => 1, %h }.perl.say; };
  > foo( { b => 2 } );
  {"a" => 1, "b" => 2}
  > foo( { } );
  {"a" => 1}
  > foo( );
  {"a" => 1}
  >

We need tests for optional array and hash parameters in the test suite,
so assigning ticket to moritz. Thanks!

Pm

@p6rt p6rt closed this as completed Jan 11, 2009
@p6rt
Copy link
Author

p6rt commented Jan 11, 2009

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

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