# New Ticket Created by "brian d foy"
# Please include the string: [perl #132980]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=132980 >
I was playing with coercion types and wondered what would happen if
a .Int method did not return the right sort of type:
class Foo {
method Int ( --> Str ) { 'Hello' }
}
put try-it( Foo.new );
sub try-it ( Int() $n ) { "Got <$n> of type <{$n.^name}>" }
Although the subroutine signature demanded an Int, it accepted
something that claimed to be able to convert but actually didn't:
Got <Hello> of type <Str>
I would have expected the runtime constraint to check the ultimate
value against the type and this would have failed.
--
brian d foy <[email protected]>
http://www.pair.com/~comdog/