# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #112922]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112922 >


< masak> r: sub foo(Bool $b = sub { False }) {}; say "alive"
<p6eval> rakudo abb8f3: OUTPUT«alive␤»
<jnthn> r: sub foo(Bool $b = sub { False }) {}; foo(); say "alive"
<p6eval> rakudo abb8f3: OUTPUT«Nominal type check failed for parameter
'$b'; expected Bool but got Sub instead [...]
<jnthn> phew
<masak> :)
<masak> jnthn: would it be possible to get a compiler warning (or even
an error) for the case of non-smartmatching defaults?
<jnthn> masak: If you mean "non-typechecking"?
<jnthn> Then probably, yes.
<jnthn> If we know the type of the RHS, which we do in this case.
<jnthn> Guess an error is fine.
<jnthn> I mean, if it's gonna fail anyway... :)
<masak> not necessarily.
<masak> not if you always call it with the argument provided.
<masak> but it's a ticking bomb, for sure.
<masak> jnthn: will you be helped by me submitting a TODO RT ticket 'bout it?
<masak> should I make a spec change saying that copmpilers should
explicitly check for this?
<jnthn> masak: We don't tend to spec such things as "must". But a TODO
RT is fine.
<jnthn> Or just implement it...it's only gonna be 3 or so lines of code. :)
* masak submits TODO rakudobug, and might come around to implementing it leytur
<jnthn> (in parameter action method...you already have the
nominal_type to hand, and can see if the default has a known compile
time value, which we already consider anyway)

Reply via email to