wavefnd / wavefnd/Wave

Surface invalid async sleep durations instead of discarding timer errors

Open
#535 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

`std::task::sleep_ms` exposes `Future`, but its shared timer-interest path represents invalid durations as an i32 error result. `_interest` rejects negative sleeps and deadline overflow with `-22`. That payload cannot be observed through the void future, so `block_on(sleep_ms(-1))` can complete as if the request succeeded.

This should be resolved within the existing error/API style; it is not a proposal for new exception syntax.

Source evidence at the head of #520:

- [std/task.wave:385](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/std/task.wave#L385) — `pub fun sleep_ms`
- [std/task.wave:358](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/std/task.wave#L358) — `export(c, "__wave_task_interest")`
- [llvm/src/expression/rvalue/async_runtime.rs:93](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/llvm/src/expression/rvalue/async_runtime.rs#L93) — `__wave_async_sleep`

Acceptance:

- [ ] Choose an observable failure path for invalid input and deadline overflow, consistent with the existing task and time APIs.
- [ ] Cover negative, zero, small positive and overflowing durations using a controllable clock where necessary.
- [ ] Ensure the compiler-generated sleep result layout matches the public API and no error payload is silently discarded.
- [ ] Keep ordinary non-async main supported.

Related: #444.

Audit status: identified by static source inspection; the scenarios above have not been executed during this audit. This follows up the implementation introduced in draft PR #520.

Contributor guide

Open the contributing guide

Research direction

Start by reading std/task.wave around sleep_ms and __wave_task_interest, then follow llvm/src/expression/rvalue/async_runtime.rs at __wave_async_sleep. Exercise negative, zero, small positive, and overflowing durations with a controllable clock where needed, including ordinary non-async main. Done means invalid inputs are observable, generated result layout matches the public API, and no timer error payload is discarded.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.