Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect assert in the example #13

Open
Egor-Skriptunoff opened this issue Feb 1, 2019 · 0 comments
Open

Incorrect assert in the example #13

Egor-Skriptunoff opened this issue Feb 1, 2019 · 0 comments

Comments

@Egor-Skriptunoff
Copy link

There is a pointless assert in the example of "beautiful asynchronous code":

   local co = assert(coroutine.running(), "Should be run in a coroutine")

Since Lua 5.2, the first value returned by coroutine.running() is always truthy.
Probably, the second returned value must be inspected instead of the first one?
Something like the following:

   local co, is_main = coroutine.running()
   assert(not is_main, "Should be run in a coroutine")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant