# New Ticket Created by Sam S.
# Please include the string: [perl #125242]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=125242 >
Trying to call the .perl method on a Hash object which has an explicit type
constraint for its keys, fails with an exception.
Example with a newly instantiated, empty Hash[Str,Any] object:
→ say Hash[Str,Any].new.perl
Cannot call infix:<===>(Str, Mu); none of these signatures match:
(Any $?)
(Any $a, Any $b)
(Int:D \a, Int:D \b)
(int $a, int $b)
(Num:D \a, Num:D \b)
(Num $ where { ... }, Num $ where { ... })
(num $a, num $b --> Bool)
(Str:D \a, Str:D \b --> Bool)
(str $a, str $b --> Bool)
in block <unit> at -e:1
in any <unit-outer> at -e:1
Example with a non-empty Hash[Any,Any] object returned by .classify:
→ say [2, 2.0].classify(*.Int).perl
Cannot call infix:<===>(Any, Mu); none of these signatures match:
(Any $?)
(Any $a, Any $b)
(Int:D \a, Int:D \b)
(int $a, int $b)
(Num:D \a, Num:D \b)
(Num $ where { ... }, Num $ where { ... })
(num $a, num $b --> Bool)
(Str:D \a, Str:D \b --> Bool)
(str $a, str $b --> Bool)
in block <unit> at -e:1
in any <unit-outer> at -e:1
Iterating over the contents of the hash and calling .perl on individual pairs,
works just fine:
→ say .perl for [2, 2.0].classify(*.Int)
2 => [2, 2.0]
It also works fine for hashes that *don't* have a custom type constraint on the
keys, even if they have a constraint on the values:
→ say Hash[Any].new.perl
Hash[Any].new()