Skip to content

Commit be9b155

Browse files
committed
return type constraints match undefined values
1 parent 1d028e1 commit be9b155

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doc/Type/Signature.pod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,13 @@ the signature after the argument name.
195195
The token C<-->> followed by a type will force a type check on successful
196196
execution of a routine. The return type arrow has to be placed at the end of
197197
the parameter list. The keyword C<returns> following a signature declaration
198-
has the same function. C<Nil> is considered as being defined for the type check.
198+
has the same function. C<Nil> is considered as being defined for the type
199+
check. Type objects and thus undefined values will pass the test unless the
200+
type smiley C<:D> is used.
199201
200202
201-
sub foo(--> Int) { 1 };
203+
sub foo(--> Int) { my Int $i; $i };
204+
sub foo(--> Int:D) { 1 }
202205
sub foo() returns Int { 1 };
203206
sub does-not-work(--> Int) { "" }; # throws X::TypeCheck::Return
204207

0 commit comments

Comments
 (0)