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

Maybe fix Coroutine.wrap? #3752

Open
wants to merge 2 commits into
base: master-MC1.12
Choose a base branch
from

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