# New Ticket Created by Zefram
# Please include the string: [perl #120480]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=120480 >
src/main.nqp features this code:
# Bump up recursion limit, for VMs that have one.
$comp.recursion_limit(100000);
The code and comment do not match: the comment says that the recursion
limit is being raised, but the code unconditionally *sets* the limit.
If the VM defaults to a recursion limit greater than 100000, or to no
limit, and then honours the requested limit of 100000, the effect of
the code is to *reduce* the limit, contrary to the comment.
The only way the code and comment could be interpreted as matching is
if every VM with a settable recursion limit were obliged to default it
to less than 100000. Currently Parrot does have such a low default
limit, and the JVM doesn't have any settable limit, so both actually
satisfy this. But there doesn't seem to be any such requirement in the
Perl6::Compiler API, so a future backend would presumably be free to
do otherwise.
The trivial way to make the code consistent is to change the comment:
# Set recursion limit, for VMs that have one.
$comp.recursion_limit(100000);
The other way is to change the code. Any code change that better matches
the comment requires reading the recursion limit, which is not currently
part of the Perl6::Compiler API. Independent of which way this particular
issue is resolved, if there's any support for setting a recursion limit
there should probably be support for reading it too.
Presuming such an addition to the API, the code can be made to match
the comment by unconditionally increasing the limit (modulo infinity
and overflow):
# Bump up recursion limit, for VMs that have one.
$comp.recursion_limit($comp.recursion_limit + 100000);
What I suspect is the real intent of this code doesn't match either the
comment or the code:
# Bump up recursion limit, for VMs that default to a low limit.
$comp.recursion_limit(100000) if $comp.recursion_limit < 100000;
-zefram