Log In  


Cart #bug_anon_inline_func-0 | 2020-11-05 | Code ▽ | Embed ▽ | No License

I'm trying to use anonymous inline functions and I'm finding some weird behavior when they are on tabs.

Putting everything in tab #0 works:

x=1
function _draw()
 cls(1)
 print('x is '..x)
end

(function()
 x=2
end)()

And moving the inline function call to tab #1 works:

x=1
function _draw()
 cls(1)
 print('x is '..x)
end

-->8
(function()
 x=3
end)()

But putting an inline function call on both tab #0 and tab #1 does not work:

x=1
function _draw()
 cls(1)
 print('x is '..x)
end

(function()
 x=2
end)()

-->8
(function()
 x=3
end)()

I don't understand why. It gives this error:

runtime error line 7 tab 0
(function()
attempt to call a nil value
at line 7 (tab 0)



[Please log in to post a comment]