Skip to content

Result of task.spawn cannot be used with coroutine.status #522

@vocksel

Description

@vocksel

The return value of task.spawn doesn't actually seem to return a thread. At least not in a way that coroutine.status recognizes.

When attempting to pass the thread in, coroutine.status errors with invalid argument #1 to 'status' (thread expected, got function)

Minimal repro:

-- scripts/repro.luau
local task = require("@lute/task")

local thread = task.spawn(function()
	print("do something for a while")
	task.wait(2)
	print("done")
end)

local status = coroutine.status(thread)

print(status)

And here's the output:

➜  flipbook git:(main) ✗ lute --version         
0.1.0-nightly.20251104
➜  flipbook git:(main) ✗ lute scripts/repro.luau
do something for a while
./scripts/repro.luau:9: invalid argument #1 to 'status' (thread expected, got function)
stacktrace:
[C] function status
./scripts/repro.luau:9
done

Metadata

Metadata

Assignees

Labels

runtimeWork in the C++ runtime portion of the code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions