# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #125988] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=125988 >
<masak_venue> m: sub foo( Str &b:(Bool --> Int) ) { say "alive" }; foo( sub (Bool) { 42 } ) <camelia> rakudo-moar e6f360: OUTPUT«Type check failed in binding &b; expected 'Callable[Str]' but got 'Sub' in sub foo at /tmp/fBPFLs3lWv:1 in block <unit> at /tmp/fBPFLs3lWv:1» * masak_venue submits rakudobug <jnthn> masak_venue: Wait, why? <masak_venue> (it ignores the inner/Int return type directive) <jnthn> Oh... <masak_venue> I think it should fail by forbidding doubly declaring it like that <jnthn> Yeah, there's precedent for trying to catch such thinkos <masak_venue> jnthn: yes, lichtkind did it by mistake and didn't even realize. <jnthn> m: my Int foo() returns Str { } <camelia> rakudo-moar e6f360: OUTPUT«===SORRY!===Type 'Int' is not declared. Did you mean 'int'?at /tmp/FG3lZlDRBh:1------> my Int ⏏foo() returns Str { }Malformed myat /tmp/FG3lZlDRBh:1------> my Int ⏏foo() returns Str { }» <masak_venue> it would be nice to catch it and throw the perfect error message <jnthn> m: my Int sub foo() returns Str { } <camelia> rakudo-moar e6f360: OUTPUT«===SORRY!=== Error while compiling /tmp/RNk5jWh_lGRedeclaration of return type for foo (previous return type was Int)at /tmp/RNk5jWh_lG:1» <jnthn> Something like that <masak_venue> yes, that one