Currently (as of August 2020) Rakudo does not typecheck the return values of functions at compile time; that is, it does not provide static guarantees that functions satisfy their return constraints. Concretely, the following two functions both compile as Raku:
sub get-int(--> Int) { 'bug' }
sub get-int($a --> Int) {
when $a == 5 { 'Rare bug' }
default { 42 }
}
I have two related questions:
Is there any way to know what (if any) typechecking currently takes place at compile time? (Either via a list someone has written, somewhere in the docs, or a central place in the Rakudo source) Or is it more ad hoc than that?
Is this lack of compile time typechecking an intentional design decision? Or is adding more static typechecking something that would be nice to have one day, but just hasn't yet been implemented?
(I'm familiar with Johnathan's great answer to The performance penalties for types/constraints in Raku?, which states that "Raku mandates that type constraints written into the program are enforced at runtime at latest." That answer describes various ways to avoid run-time costs of typechecks, but doesn't describe what, if any, typechecks are done at compile time (which would certainly avoid runtime costs!).)