Closed Benjamin-Dobell closed 5 years ago
I just tried this in the MoonSharp REPL and it works there, as expected prints "Hi".
@stever Thanks, I just checked this myself and am indeed able to get it working in the REPL (even several versions ago).
I've actually ran into this writing mods for a game for which I don't have the source, so I'm not really able to debug this at present. If I get some time I'll go setup a test project to see if I can reproduce the issue there.
Okay, I've finally worked out a proper reproduction case for this:
(function()
print('hi')
end)()
(function()
print('bye')
end)()
I had some files that were being concatenated such that I ended up with neighbouring IIFEs as above. However, this fails in regular Lua, so isn't a MoonSharp issue. So I'm closing this. Sorry for the confusion!
Moonsharp raises:
when encountering an immediate invocation of an anonymous function e.g.
This syntax works in at least the Lua CLI, I'm not sure about other runtimes.
Honestly, it's not a major issue, but I couldn't find this documented anywhere, and it would of course be nice to have more compatibility if possible 😄
Anyway, thanks for all the hard work put into Moonsharp, it's pretty great!