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

Owner: Nobody
Requestors: zefram [at]

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

From: Zefram <zefram [...]>
Date: Mon, 15 Aug 2016 01:15:51 +0100
To: rakudobug [...]
Subject: [BUG] .WHICH doesn't distinguish between instances of identically-named classes
Download (untitled) / with headers
text/plain 1.1k
Show quoted text
> my $n = { my class Num {} }().new; my $m = $n.WHICH.Str.split("|")[1].Num; for $n, $m { say (.WHICH, .^methods.elems) }
(Num|47923715919504 0) (Num|47923715919504 63) I have here two distinct objects, of different classes, with the same .WHICH string. One is an instance of an empty class I've just defined, and the other is a floating-point value in a built-in class. In the above you can see that they really are of these two different classes from the different lengths of their method lists. This is related to [perl #128931], about .WHICH not distinguishing identically-named classes, but there's a bit more to this. .WHICH applied to the two Num classes in the above duly shows "Num" for both, so fails to distinguish the class objects. But if given instances of two user-defined classes, I think the object IDs that go into the default .WHICH would be unique across all the classes, so the .WHICHes wouldn't clash. The above clash depends on the non-default .WHICH arrangement for the built-in Num class. Many other classes could produce similar clashes; generally, custom .WHICH methods are relying on the class part of a .WHICH string uniquely identifying the class. -zefram

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

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