Skip to content

Commit 417fbfe

Browse files
authored
Indicate Nil/Failure are exempt from return constraints
1 parent 5f8fb85 commit 417fbfe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/Language/functions.pod6

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ Attempting to return values of another type will cause a compilation error.
187187
188188
sub foo() returns Int { "a"; }; foo; # Type check fails
189189
190+
Note that C<Nil> and C<Failure> are excempt from return type constraints and
191+
can be returned from any routine, regardless of its constraint:
192+
193+
sub foo() returns Int { fail }; foo; # Failure returned
194+
sub foo() returns Int { return }; foo; # Nil returned
195+
190196
=head2 X<Multi-dispatch|declarator,multi>
191197
192198
Perl 6 allows you to write several routines with the same name, but different

0 commit comments

Comments
 (0)