Skip to content

Commit e696e37

Browse files
authored
Merge pull request #2346 from nxadm/master
Document typing of returns in signature
2 parents 435be23 + 0eb8d39 commit e696e37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

doc/Language/typesystem.pod6

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,13 @@ will be checked against the given code object.
846846
CATCH { default { put .^name,': ', .Str } }
847847
# OUTPUT: «X::TypeCheck::Assignment: Type check failed in assignment to $i; expected Positive but got Int (-42)␤»
848848
849+
Subsets can be used in signatures, e.g. by typing the output:
850+
subset Foo of List where (Int,Str);
851+
sub a($a, $b, --> Foo) { $a, $b }
852+
# Only a List with the first element beint an Int and the second a Str will pass the type check.
853+
a(1,"foo"); # passes
854+
a("foo", 1); # fails
855+
849856
Subsets can be anonymous, allowing inline placements where a subset is required
850857
but a name is neither needed nor desirable.
851858

0 commit comments

Comments
 (0)