Closed bobbimanners closed 6 years ago
Code above should read:
sub recurse3(word x)
if x==0
return 1;
else
return x*recurse3(x-1)
endif
endsub
Even with this silly issue fixed however, the issue remains the same. Works fine when interpreted but not when compiled for x>1. Always returns 1 when compiled. If the code is changed to return recurse3(x-1) * x
then it works. Not clear why.
It seems the problem here is that the parser muddles up the outer (x function_call) and the inner (x-1) expressions somehow. The code emitted seems to try to calculate xx-1. This is probably a bug in the function call logic (which is a hack anyhow).
Fixed in v0.62. The problem was that the compiler was omitting to push SENTINEL to the operator stack before evaluating the function's operand, and pop it afterwards. As a result the parsing was getting confused.
This works okay in the interpreter but the compiled code does not run. Swapping the order of the arguments to the multiplication resolves the issue!