Skip to content

Instantly share code, notes, and snippets.

@zengargoyle
Last active October 31, 2015 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zengargoyle/5ba20a3c5799327b44d0 to your computer and use it in GitHub Desktop.
Save zengargoyle/5ba20a3c5799327b44d0 to your computer and use it in GitHub Desktop.
use Test;
my $i = (1,2,3);
my %h{Any};
%h{$i} = 'foo';
is %h{$i}:exists, True, 'key exists';
is %h.EXISTS-KEY($i), True, 'this works';
# maybe rest is not bug but wrong usage causing BOOM
#
my %s;
my $x = 'hello';
%s<<$x>> = 'foo';
is %s<<hello>>, 'foo', 'got foo <<no-var>>';
is %s<<$x>>, 'foo', 'got foo <<$var>>';
is %s{"$x"}, 'foo', 'got foo {"$var"}';
%s{"$i"} = 'bar';
# is $s<<$i>>, 'bar', 'blows up ugly';
is %s{"$i"}, 'bar', 'works with {"$i"}';
done-testing;
$ perl6 bug-hash.p6
not ok 1 - key exists
# Failed test 'key exists'
# at bug-hash.p6 line 8
# expected: 'True'
# got: 'False False False'
ok 2 - this works
ok 3 - got foo <<no-var>>
ok 4 - got foo <<$var>>
ok 5 - got foo {"$var"}
ok 6 - works with {"$i"}
1..6
# Looks like you failed 1 test of 6
$ perl6 --version
This is perl6 version 2015.10-16-g2f4bfd8 built on MoarVM version 2015.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment