Hi Imp, there’s a bug with variables in closures defined inside generators. I confirmed it was present in upstream Squirrel too, so reported it there (issue here). It’s been fixed now, and it looks like a very easy fix, so hopefully you can apply it to the Imp implementation soon. You can check out the fix in this commit.
We should be able to get this into release 40, which is just about to enter external testing.