On Tue, 23 May 2017 14:36:55 -0700, comdog wrote: > .invert doesn't do what it says on the tin. From > https://docs.perl6.org/type/Pair#method_invert > > my Pair $p1 = (6 => 'Perl'); > say $p1.invert; # OUTPUT: «Perl => 6» > say $p1.invert.WHAT; # OUTPUT: «(Pair)» > > my Pair $p2 = ('Perl' => (5, 6)); > say $p2.invert; # OUTPUT: «(5 => > Perl 6 => Perl)» > say $p2.invert.WHAT; # OUTPUT: «(List)» > > my Pair $p3 = ('Perl' => { cool => 'language'}); > say $p3.invert; # OUTPUT: «{cool > => language => Perl}» > say $p3.invert.WHAT; # OUTPUT: «(Hash)» > > I get sequences instead: > > (Perl => 6) > (Seq) > (5 => Perl 6 => Perl) > (Seq) > ((cool => language) => Perl) > (Seq) > > % perl6 -v > This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda > implementing Perl 6.c.
Thank you for the report. This issue is now resolved. While it was fixed accidentally[^1], the old behaviour was inconsistent with the .invert on the other types, and looking at the [^2] spec tests for it, it appears due to faulty tests, they were passing for the wrong reason. The tests index `[0]` the return value without checking what they're indexing, so the returned Pair was simply treated as a 1-item list automatically. I added[^3] more roast tests to spec Pair.invert as always returning a Seq and fixed[^4] the docs to reflect the correct behaviour. [1] https://github.com/rakudo/rakudo/commit/7ea0f66189 [2] https://github.com/perl6/roast/blob/6.c-errata/S02-types/pair.t#L330-L332 [3] https://github.com/perl6/roast/commit/f4828aaf64 [4] https://github.com/perl6/doc/commit/edd74317341a23