Is this a known issue, or my misunderstanding?

> subset non-Nil where * !=== Nil;
(non-Nil)
> sub out-check($out) returns non-Nil { return $out }
&out-check
> out-check(44)
44
> out-check(Nil)
Nil

^ Huh, I expected an exception on "out-check(Nil)" saying the return value
failed the "returns" constraint.

The subtype works as I expect as an the argument check

> sub in-check (non-Nil $in) { $in }
&in-check
> in-check(33)
33
> in-check(Nil)
Constraint type check failed in binding to parameter '$in'; expected
non-Nil but got Nil (Nil)
  in sub in-check at <unknown file> line 1
  in block <unit> at <unknown file> line 1

$ raku --version
This is Rakudo version 2020.07 built on MoarVM version 2020.07
implementing Raku 6.d.

Is this my understanding of return type checking that's off, or a known
issue, or something I should add to an issue tracker?

-y

Reply via email to