Skip to content

Conversation

@zeng-github01
Copy link

Fix #3687

@zeng-github01 zeng-github01 changed the title Maybe fix Maybe fix Coroutine.wrap? Jan 7, 2025
@SquidDev
Copy link
Contributor

SquidDev commented Jan 7, 2025

I think this needs to handle the case where the coroutine returns multiple values. I think if you use table.pack, you can get something closer to what PUC Lua does:

    local result_pack = table.pack(coroutine.resume(thread, ...))
    if not result_pack[1] then error(result_pack[2], 2) end
    return table.unpack(result_pack, 2, result_pack.n)

@zeng-github01
Copy link
Author

zeng-github01 commented Jan 7, 2025

I think this needs to handle the case where the coroutine returns multiple values. I think if you use table.pack, you can get something closer to what PUC Lua does:

    local result_pack = table.pack(coroutine.resume(thread, ...))
    if not result_pack[1] then error(result_pack[2], 2) end
    return table.unpack(result_pack, 2, result_pack.n)

This looks like a restoration of the past implementation.
Why did they change it to this? It's really strange.

Do you consider submitting a PR? I'm not good at Lua. I'm worried about new problems.

@zeng-github01 zeng-github01 marked this pull request as draft January 7, 2025 16:37
@zeng-github01 zeng-github01 marked this pull request as ready for review January 8, 2025 16:03
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

Successfully merging this pull request may close these issues.

2 participants