[r111] Func doesn't continue after recursive call

Bugs will be moved here once resolved.

Post » Sun Dec 09, 2012 2:09 am

I was showing off my maze capx and then bam... broken.

I was able to recreate the bug in a simple capx.

Basically, if you still have stuff to do after a recursive call, well... it's ignored.


Here's the simple capx.
functionStopsOnRecursion.capx

If you run the capx, nothing gets displayed.
But if you put the
Code: Select all
Text: Append first&newline
before the functionn call (event 3), it works as expected.Yann2012-12-09 02:10:13
Last edited by Yann on Sun Sep 14, 2014 8:22 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Dec 09, 2012 4:16 am

Small clarification: The code is actually called, but the local variables are not maintained. Looks like this bug may have come back:

Local non-static variables in recursive functions did not hold unique values at each level of recursion (they acted like global variables throughout the function call). Now their values work independently in each call.

@Yann, change your text to: "["&first&"]"&newline

The code is being called, but it was only showing newlines. Now you'll see text is being output.
ImageImageImage
B
67
S
19
G
124
Posts: 3,219
Reputation: 74,425

Post » Mon Dec 10, 2012 2:21 am

@blackhornet
Alright, thanks for the clarification. I must admit that I encountered this bug in a more complex situation (a maze generator) and it behaved as if the function stopped, but it could as well be due to wrong variable values (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Dec 11, 2012 5:08 pm

Thanks, should be fixed in the next build... but recursive functions are proving tricky to get right!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Wed Dec 12, 2012 1:02 am

@Ashley
I can only imagine the complexity of that. Thanks for your effort (:

I think functions can greatly increase the readability of a capx (and then teamwork), that's why I'm focusing on it these days and stress-test them.

Thanks to them, I am now able to more easily separate chunks of event and avoid undesirable interactions (which makes modifying/extending/refactoring some events that much easier)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Dec 12, 2012 1:18 am

Oh new version is already up!
Alright I tested the capx I provided and my good old maze capx, all is working super fine thanks (:
(that won't stop me from continuing to torture these functions though mwahahahah!)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest