The LuaJIT version that Garry's Mod is using is outdated and that's bad. Here's why.

While changing stuff in one of my scripts, some parts of the new code behaved in a weird way,
so I decided to investigate.
I was able to create a simple example script that demonstrates what’s wrong:

Edit: Solved:

Also going to mention that coroutines behave differently depending on if they were ran on the jit enviroment or not.