Direct calls to lambdas inside a vector


I have one class that just holds values.

// Timer class
class Timer
    var id
    var callback
    var current
    var last
    var count
    var step
    def Timer(id, callback, step, count)
    { = id
        this.callback = callback
        this.count = count
        this.step = step
        this.current = 0
        this.last = 0

and one variable that holds a vector of this class

var timers = []

I do push elements to this vector using

timers.push_back(Timer(0, def() { print("hello world"); }, 0, 0);

each game iteraction, I do update this timers using the following script, but the problem is that I can’t call the callback directly, like:

for (var i = 0; i < timers.size(); i += 1)

no exception is thrown, but the lambda isn’t getting called. I found that if I change the code to this:

for (var i = 0; i < timers.size(); i += 1)
    var cb = timers[i].callback

the script works just fine.

Is this a bug, or what?



Looks like a bug, please open an issue on the github bug tracker



hmm, on second thought, I’m not sure what my options would be there to make that parsing work. Could you try this:


And let me know if that works please?




doesn’t seems to solve the problem.


I’ve filled a bug report on github here:

I’ll be watching the issue on github.


The github issue has been closed. Calling functions contained in other objects should work in many more contexts now.