Skip to content

Commit cc2d14b

Browse files
committed
Make Signature.pod6 compilable with small example code fixes
Missed names, semicolons or exception catches.
1 parent 076e7ff commit cc2d14b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

doc/Type/Signature.pod6

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ can be used to that effect.
169169
sub f(*@a where {$_.all ~~ Int}) { say @a };
170170
f(42);
171171
f(<a>);
172+
CATCH { default { say .^name, ' ==> ', .Str } }
172173
# OUTPUT«[42]␤Constraint type check failed for parameter '@a'␤ in sub f at ...»
173174
174175
=head3 Constraining named Arguments
@@ -245,9 +246,9 @@ has the same function. C<Nil> and its subclasses do B<not> abide by return
245246
constraints. This allows L<Failure|/type/Failure> to be returned and passed on
246247
down the call chain.
247248
248-
sub(--> Int) { my Int $i; $i };
249-
sub(--> Int:D) { 1 }
250-
sub() returns Int { 1 };
249+
sub foo(--> Int) { my Int $i; $i };
250+
sub baz(--> Int:D) { 1 }
251+
sub bar() returns Int { 1 };
251252
sub does-not-work(--> Int) { "" }; # throws X::TypeCheck::Return
252253
253254
If the type constraint is a constant expression, it is used as the return value
@@ -345,7 +346,7 @@ dissolving one or more layers of bare C<Iterables>.
345346
my @array = <a b c>;
346347
my $list := <d e f>;
347348
sub a(*@a) { @a.perl.say };
348-
a(@array) # ["a", "b", "c"]
349+
a(@array); # ["a", "b", "c"]
349350
a(1, $list, [2, 3]); # [1, "d", "e", "f", 2, 3]
350351
a([1, 2]); # [1, 2]
351352
a(1, [1, 2], ([3, 4], 5)); # [1, 1, 2, 3, 4 5]

0 commit comments

Comments
 (0)