Actions
Bug #12905
closedtailcall_optimization not working as expected under certain condition order
Bug #12905:
tailcall_optimization not working as expected under certain condition order
Description
Below code gets stack too deep error:
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
def run_forever(current, final)
if current < final
run_forever(current+1, final)
else
nil
end
end
run_forever(1, Float::INFINITY)
However, below code works as expected:
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
def run_forever(current, final)
if current >= final
nil
else
run_forever(current+1, final)
end
end
run_forever(1, Float::INFINITY)
Thanks for looking at this :)
Actions