Document the behavior of `try` and `$!` if no Exception is thrown
The page on exceptions and the section on the try statement modifier currently don't say what happens when everything goes fine and no Exception is thrown/caught. The only thing in that direction is the general statement
Caught exceptions are stored inside the $! variable, which holds a value of type Exception.
The docs should say explicitly what to expect for the value of $! if no Exception is thrown.
De facto it's (Any):
> try { }; say $!
(Any)
I'm not sure though it's specced that way, or if this value is more an accidental feature of the Rakudo implementation.
> try { }; say $! (Any)I'm not sure though it's specced that way, or if this value is more an accidental feature of the Rakudo implementation.
"specced" = roasted.
A search of roast for $! (plus some exploration of the results and blame) suggests that S02-magicals/dollar_bang.t is the pertinent part of the spec, and in particular this fragment:
try { die "foo" };
ok defined($!), 'error in try makes $! defined';
try { 1 };
nok $!.defined, 'successful try { } resets $!';
My interpretation of those tests is that an implementation is correct according to the spec (roast) if, after a try is complete, $!.defined is True if an exception was thrown during execution of the try and False otherwise.
I believe PR 4733 addresses this issue in full.