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

Lists as hash keys: an inconsistency between assignment and binding #5451

Open
p6rt opened this issue Jul 14, 2016 · 1 comment
Open

Lists as hash keys: an inconsistency between assignment and binding #5451

p6rt opened this issue Jul 14, 2016 · 1 comment

Comments

@p6rt
Copy link

p6rt commented Jul 14, 2016

Migrated from rt.perl.org#128619 (status was 'new')

Searchable as RT128619$

@p6rt
Copy link
Author

p6rt commented Jul 14, 2016

From roam@ringlet.net

Hi,

As discussed a bit on IRC from https://irclog.perlgeek.de/perl6/2016-07-14#i_12840543 until about https://irclog.perlgeek.de/perl6/2016-07-14#i_12840653

In a hash that accepts arbitrary objects as keys, an assignment using a list-like variable as a key works, but a binding interprets the list nature of the variable as a hash slice and fails​:

17​:02 < lizmat> m​: my %h{Any}; my $key = slip("a",); %h{$key} = 1; dd %h # if this works
17​:02 <+camelia> rakudo-moar 527f8d​: OUTPUT«Hash[Any,Any] %h = (my Any %{Any} = (slip("a",)) => 1)␤»
17​:02 < lizmat> m​: my %h{Any}; my $key = slip("a",); %h{$key} := 1; dd %h # then this should work as well
17​:02 <+camelia> rakudo-moar 527f8d​: OUTPUT«Cannot bind to Hash[Any,Any] slice␤ in block <unit> at <tmp> line 1␤␤»

As noted there, I'd be perfectly fine with a "make the assignment treat it as a slice too, then rethink your program and don't use lists as keys" resolution, but right now the behavior is inconsistent.

Thanks for developing Perl 6 so far that the problems that need to be reported are as hairy and obscure as this one! :)

G'luck,
Peter

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