Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make (1,2,3,4,1,2).QuantHash>>-- work
Spotted in #5057 . The above basically runs QuantHash.new(1,2,3,4,1,2).deepmap(&postfix:<-->) The problem was caused by there being an Associative candidate for deepmap, and QuantHashes being Associative. Since .deepmap is supposed to *return* an object of the *same* type, this effectively means a new object needs to be created. In the case of the code in the issue, essentially: $ raku -e 'my $a=‘abcdeabc’.comb.BagHash»--; $a.keys.sort.say' there would be a BagHash object created, but then the deepmap logic for Associatives would do some magic that would do the wrong thing for QuantHashes (and possibly for Hash and Map as well, but that requires further investigation). The result was that the order in which updates where being done, got confused, and the new BagHash object got mutilated. This commit adds specific Setty, Baggy and Mixy candidates for deepmap, that actually uses information about the internal structure of the QuantHashes to allow a fast creation of the new, updated object. This allows >>-- to even work on immutable QuantHashes (as we create a new immutable object under the hood). So this now works: $ raku -e 'say ‘abcdeabc’.comb.Bag»--' Bag(a b c)
- Loading branch information