Skip Menu |
Report information
Id: 128619
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: roam [at] ringlet.net
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Lists as hash keys: an inconsistency between assignment and binding
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org