# New Ticket Created by  Zoffix Znet 
# Please include the string:  [perl #131505]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131505 >


(found in discussion in https://rt.perl.org/Ticket/Display.html?id=131493 )


We have some special casing for coercion of allomorphs in some instances, which
is done so there'd be some way to force one of the two types to fall out of it,
since we have types where to whom object identity matters a bunch:

    <Zoffix__> m: <1>.Str.^name.say
    <camelia> rakudo-moar 7344a3: OUTPUT: «Str␤»
    <Zoffix__> m: <1>.Int.^name.say
    <camelia> rakudo-moar 3755c0: OUTPUT: «Int␤»

However, allomorphs don't get coerced with parameter coercers and possibly some
other places. There's no special casing here done. The coercer coerces to Str 
type
and IntStr allomorph is already it.

    <Zoffix__> m: -> Str() $_ { .^name.say }(<1>)
    <camelia> rakudo-moar 7344a3: OUTPUT: «IntStr␤»
    <Zoffix__> m: -> Int() $_ { .^name.say }(<1>)
    <camelia> rakudo-moar 7344a3: OUTPUT: «IntStr␤»


So the question becomes: do we special case allomorphs everywhere?

- If yes, any place we special case them will have a caveat and surprising 
behaviour
    where type don't get coerced to exact asked type if it's a subclass of it
- If no, we get surprising special cased behaviour like above, but only in one 
case
- Or we could remove the coercion to one of the two types and have <1>.Str 
return the same
   IntStr; in that case I'm unsure what would be a way to "collapse" an 
allomorph into
   numeric or string parts, since many ops use these methods to coerce stuff.

Reply via email to